Re: Poroposal: PEAR:DB package - SQLite

From: Date: Fri, 13 Jun 2003 00:46:51 +0000
Subject: Re: Poroposal: PEAR:DB package - SQLite
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17365@lists.php.net to get a copy of this message
----- Original Message ----- From: "Urs Gehrig" <urs@circle.ch> To: <pear-dev@lists.php.net> Sent: Wednesday, June 11, 2003 6:19 PM Subject: [PEAR-DEV] Poroposal: PEAR:DB package - SQLite > dear all > > i have been working on a sqlite wrapper for PEAR:DB. sqlite > is different from the other databases in the way, that i does > not need a server to run; on windows it is a single exe file > (sqlite.exe) and on debian e.g. you can install sqlite > like "apt-get install sqlite". > > so the dsn is not really used in a way as we need to pass > a username, a password or a host. but the databasename is > used of course. > > so i used the PEAR:DB dsn as followed, while dummy as user > and host as host is just not needed: > > $dsn = "sqlite://dummy:@host/c:/tmp/database.db" > or > $dsn = array ( > 'phptype' => "sqlite", > 'databse' => "c:/tmp/database.db", > 'mode' => 0777 > ); > or > $dsn = "sqlite:///c:/tmp/database.db" > > so far, the wrapper can be called like most db wrappers too. > please have a look at the test script > > $db = &new DB_sqlite(); > $db->connect("sqlite:///c:/tmp/database.db" ); > $result = $db->query("SELECT * FROM table;" ); > print_r($result ); > $db->disconnect(); > > you can get more information under the following link: > http://www.circle.ch/php/files/DB_sqlite/20030530/ > > i would like to propose that wrapper for PEAR. it works as > well on debian linux as on windows 2000, as far as i could > test it. > > sqlite is designed to be used in fast applications; nevertheless > there are some good points to have a kind of standardized > calls for those db functions. > > running "php -f sqlite1.php" will create a new database > automatically called ./test1.db . within that db, several > tables will be created an altered. > > sqlite is availabe through http://sqlite.org too. > > thanx for feedback. comments are welcome. > I took a look at the class and it's quiet good. Please commit it. Some comments about the implementation: - Error code map should map to the native DB ones, not sqllite ones. I would recommend you to create a sqlLiteRaiseError() func for the mapping and native error. - fetchInto() or query() should get only one row of data, not all. If you want all the data in an array just use getAll(). - You can safely from fetchRow - In the possible mesure follow the PEAR coding standar, specially the if () { one (sorry if I sound boring). - As sqlLite supports last_insert_rowid, I guess the sequences emulation could be easily implemented. - You could try to run the test suite to document the level of conformance of the class. Tomas V.V.Cox

« previous php.pear.dev (#17365) next »