Inserting and pulling images from sql [solved]
-
Is there a way to insert and pull images from a sql db? I can do it with text but can't figure out how to do it with images.
here is what I'm doing for inserting and grabbing txt is there a way to change this up so I can use it for images?
@
var index_count = 0
var up_check = 0
var r = "rr"function get_db(a, up_check) {
var db = LocalStorage.openDatabaseSync("DB5", "1.0", "The Example QML SQL!",
1000000);
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT,
salutee TEXT)');
for ( var z=0; z<1000; z++){
tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'Movie', z ]);
}
var rs = tx.executeSql('SELECT * FROM Greeting');
r=""
if (index_count <0)
index_count=0;
// for(var i = 0; i < sa; i++) {
if (up_check === 0)
r += rs.rows.item(index_count).salutation + ": " +
rs.rows.item(index_count).salutee + "\t\t"
if (up_check === 1){
r += rs.rows.item(index_count).salutation + ": " +
rs.rows.item(index_count).salutee + "\t\t"
}
}
//}
)
console.log(r);
index_count=a;
return r;
}
@ -
Maybe I should restate this question.
How can I have a folder of say 1000 images loaded in a db to be used like and array or var -
I am not sure if it is a good practice to store images into database. You should define your column as BLOB. You will need to write some C++ class to get binary data of image you want to save. and to display image from binary data retrieved from DB.
As for me I would save images in file system and store their paths in database, I think that it is better and more simple solution.