Exemplo n.º 1
0
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val)
{
	// convert a blob to a an unsigned char* array
	const unsigned char* pData = reinterpret_cast<const unsigned char*>(val.rawContent());
	int valSize = static_cast<int>(val.size());

	int rc = sqlite3_bind_blob(_pStmt, static_cast<int>(pos), pData, valSize, SQLITE_STATIC); // no deep copy, do not free memory
	checkReturn(rc);
}
Exemplo n.º 2
0
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
{
	if (_metadata.columnsReturned() <= pos)
        throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");

    if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
        return false;

	if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
		throw MySQLException("Extractor: not a blob");

  unsigned long length= 0;
  MYSQL_BIND bind = { 0 };
  bind.buffer= 0;
  bind.buffer_length= 0;
  bind.length= &length;
  if ( ! _stmt.fetchColumn(pos, &bind) )
    return false;

  std::vector<char> data(length);
  bind.buffer = &data[0];
  bind.buffer_length= length;
  if ( ! _stmt.fetchColumn(pos, &bind) )
    return false;

  val.assignRaw(&data[0], length);
	return true;
}
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
{
	if (_metadata.columnsReturned() <= pos)
		throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
	
	if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
	return false;
	
	if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
		throw MySQLException("Extractor: not a blob");
	
	val.assignRaw(_metadata.rawData(pos), _metadata.length(pos));
	return true;
}
Exemplo n.º 4
0
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val, Direction dir)
{
    poco_assert(dir == PD_IN);
    realBind(pos, MYSQL_TYPE_BLOB, val.rawContent(), static_cast<int>(val.size()));
}
Exemplo n.º 5
0
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val, Direction dir, const WhenNullCb& nullCb)
{
	poco_assert(dir == PD_IN);
	realBind(pos, Poco::Data::MetaColumn::FDT_BLOB, &val, static_cast<int>(val.size()));
}