Dilarion

blog o dilarion

Adobe Air : koneksi database sqlite & get last insert id

biar gak lupa, berikut snippet koneksi db di adobe air dan untuk mendapatkan last insert ID (kalau di pehape mysql_insert_id), dengan javascript :

var dnama = $('#tnama').val();
var dalamat = $('#talamat').val();

//resolve lokasi file database
var db = air.File.applicationDirectory.resolvePath("fanta.db");

//bikin koneksi db
var conn = new air.SQLConnection();

//persiapan bikin query db trus eksekusi query
var tsql = new air.SQLStatement();
tsql.text = "insert into responden (nama, alamat) values ('"+dnama+"', '"+dalamat+"')";
tsql.sqlConnection = conn;
tsql.execute();

//mendapatkan id last insert (kalau di PHP : mysql_insert_id)
result = tsql.getResult();
primekey = result.lastInsertRowID;

Tinggalkan Balasan

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>