Jump to content

PDO and Blob type with sqlite


peacemoon

Recommended Posts

 

 

i store blob data with php like this

 

$this->_db->exec"CREATE TABLE media (url TEXT, content BLOB)");

 

$fp = fopen($encoded['path'], 'rb');

$sql = "INSERT INTO media (url, content) VALUES (?, ?)";

$stmt = $this->_db->prepare($sql);

$stmt->bindValue(1, $encoded['url'], PDO::PARAM_STR);

$stmt->bindValue(2, $fp, PDO::PARAM_LOB);

$stmt->execute();

fclose($fp);

 

And in my c++ program (using bada framework) i read the data from blob column back. The problem is, when i use php on my localhost (version 5.3.2-1ubuntu4.2), my c++ app can recognize the blob column as blob type correctly. But when i use my remote host (php version 5.2.12) to create sqlite file, my c++ app recognizes the blob column as TEXT TYPE and my binary data is corrupted.

 

Does anyone know why and any work around?

 

Thanks

 

Link to comment
Share on other sites

SQLite's data types are very different to that of other databases. You in fact don't even need to declare data types for anything other than auto incrementing fields (which must be declared as INTEGER).

 

I suspect this could be the cause of your problems, unfortunately, I don't offer any solution however. You should read the Sqlite docs for further info, its been a long while since of read them.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.