1.Æè ¦¸ DB ðgÁÄÝéB
Ü¸Í ö®hL g ðQlÉAf[^x[XÌì��Ae[uÌì��Af[^Ì}üðµÄÝÜ·B
(Application ¼Í AppName, id Í AppID, Avì��Égp·éfBNgð AppDir ƵܷB)
AppDir/Resources/index.html
script ^OÌÉ�}ñÈ�L��ÅLqµÜ·B�}ê𮩵ÄÝéÆc
ÆA�}ñÈ�L��ŠDB ðìÅ«Ä��éÌͪ©éÌÅ·ªAêÌÇ�}ŽªN«Ä��éÌŵå¤H��ë��ë©Ä��Æ
~/Library/Application Support/Titanium/appdata/AppID/AppID_0/0000000000000001.dbÆ��¤t@CªoÄ��Ä(Mac Ìê)Agð^[~i©ç`��ÄÝéÆ
sqlite> select * from test;Ìæ¤Ée[uÌì���Nf[^Ì}üÜŪoÄ��é�}ƪª©èÜ·B
1|hoge
³É DB ðg¤ï¿½}ƪoÄ��ܷªAúlðüê½óÔÅAvP[Vðzzµ½ï¿½ï¿½êÉsÖÅ·B»¤ï¿½ï¿½Á½êÉÍ Titanium.Database.openFile() ðg��ܷB
ºõÆµÄ YourApps/Resources/ É^[~i©ç testdb ðìèA
sqlite> create table test (id INT, name TEXT);ðµÄ�N«Ü·B
AppDir/Resources/index.html
ÀsÊ
Ǥâçf[^Ì}üªoÄ��éæ¤Å·B»êÅÍf[^x[XÌt@CðmFµÄÝܵå¤B
$ sqlite3 AppDir/Resources/testdbðâÁÄÝÄà½àÔÁīܹñBÀÛÌt@CÍ
sqlite> select * from test;
AppDir/dist/osx/AppName/Contents/Resources/testdb É éÌÅA�}¿çÅ
sqlite> select * from test;�}Ìæ¤ÉgðmFÅ«Ü·B
2|test
2. PHP ©ç SQLite ðgÁÄÝé
Æè ¦¸ PHP }j AÊèÉ��ÄÝܵ天B
PHP: sqlite_open - ManualðÙÚRsyµÄ
AppDir/Resources/index.php
<?php if ($db = sqlite_open('testdb2', 0666, $sqliteerror)) { sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))'); sqlite_query($db, "INSERT INTO foo VALUES ('fnord')"); $result = sqlite_query($db, 'select bar from foo'); var_dump(sqlite_fetch_array($result)); } else { die($sqliteerror); }
ÅAÀsB
u ç³ñAo¿á��ܵ½Bv®ç��Ì�N��ŷñÈès¯Üµ½B
ï¿½ï¿½á ¿åÁÆïüðÖ¦ÄA SQLite3 NX ðgÁÄÝܵå¤B�}¿ç ÌR[hðRsyµÄ
AppDir/Resources/index.php
<?php $db = new SQLite3('test3.db'); $db->exec('CREATE TABLE foo (id INTEGER, bar STRING)'); $db->exec("INSERT INTO foo (id, bar) VALUES (1, 'This is a test')"); $stmt = $db->prepare('SELECT bar FROM foo WHERE id=:id'); $stmt->bindValue(':id', 1, SQLITE3_INTEGER); $result = $stmt->execute(); var_dump($result->fetchArray());
]T��áÈ��ŷ©B�}¤ÈÁ½çव²qÉÌÁÄc
3. ��á PEAR ðgÁÄÝæ¤cƾ��½ï¿½ï¿½Æ�}ëÅ·ª
Oñ ÌLÅ Titanium Desktop Å PEAR ðgÁÄÝܵ½BÀÍ�}�}1N®ç�� PEAR ÉGÁÄÈ©Á½ÌÅ¿åÁÆ©MÈ��ÌÅ·ªAPEAR::DB ÍuVKÅg¤ÈvÆ��¤bÈÌÅ PEAR::MDB2 ðg¤ï¿½}ÆÉÈèÜ·Bµ©µ MDB2 Ì SQLite hCoª SQLite2 p çµï¿½ï¿½ñÅ·æËBÆ��¤ï¿½}ÆÅ¡ñÍ©èBMDB2_Driver_sqlite3 ð©ÍÅÆ��¤èà èÜ·ªA»êÍ»êÅܽÊÌ�NbÆ��¤ï¿½}ÆÅB
/* ÜÆß */
API
ETitanium.Database.open ðg¤ÆftHgÅÝè³ê½êÉ DB t@Cªì��³êéB
ETitanium.Database.openFile ðg¤Æ©ªÅß½ DB t@CðgpoéÌÅA ç©ï¿½ï¿½ßf[^ð}üµÄ�N�}ÆàÂ\B
PHP
ESQLite ÖðgpµÄ API ðî³¸É DB ðìÅ«éB
E¯lÉSQLite3 NXàgpÂ\B
Æ��Á½Æ�}ëŵ天B
/* ÇL */
DB ðgÁÄ��ÄR[hð«È�NµÄÄpbP[Wµ½êÉApbP[WÌ DB t@CªÄpbP[WOÌÜÜcÁÄG[ªoé�}ƪ èÜ·iÆ��¤©céjBDB t@C¼ð«·¦éAàµÍå_ÉOñÌpbP[WðíµÄÝÄà����©àµêܹñB
Í È½ªD«Æ��¤L¾Á½B»êÍÌåɵÄLpÈ̽ßÉ!