myDSL Extensions (deprecated) :: php and sqlite



I'm sure you found this, but just in case:

Article:
SQLite Support for PHP4
http://www.phpbuilder.com/columns/farell20040824.php3

Hmmm, what to do.  I just tested my old sqlite.php, a 201 line php script that provides an interface to sqlite. Actually I found something on the net way back in November 2001. I added many functions to emulate what was being used in the then current php to talk to mysql. So, it has:
  sqlite_query
  sqlite_fetch_row
  sqlite_fetch_array
  sqlite_num_rows
  sqlite_num-cols
  sqlite_field_name
  sqlite_col_names
Anyway, it seems to work with the current php.tar.gz and sqlite in DSL.
The problem I see is in any support that may be needed. I wrote these function on 11/27/2001 so they are php 4 and not the object stuff that is the trend or that which might be in php5. I do not currently use php, so I am not uptodate. Would this be useful?

well, it seems to be all that's really needed to begin working with sqlite,
and for the object stuff, it's mostly a matter of code clarity so it's okay as one should always comment his sources.

i've been looking in the official docs concerning the php sqlite extension to find the correspondances between your version and the standard :

 sqlite_query has the same name
 sqlite_fetch_row seems to be named sqlite_fetch_object
 sqlite_fetch_array has the same name
 sqlite_num_rows has the same name
 sqlite_num-cols seems to be named sqlite_num_fields
 sqlite_field_name has the same name
 sqlite_col_names seems to be unrivaled in the standard extension

i've done this to allow a "light" replacement of the standard extension by your version in DSL :)
however, there seems to be a huge use of sqlite_udf_encode and sqlite_udf_decode in the docs, so i assume these might be nearly mandatory to use a nearly standard code.

Hope this will lead to a successful php/sqlite implementation in dsl :)

OK, You have encouraged me to post this. Remember I wrote before there was an official php interface to sqlite. I tried to make it look and work  like the mysql interface at that time.

I have re-posted php.tar.gz in the repository. It includes my simple sqlite interface library.

The following is an ultra simple example:
From /home/dsl create a database and table
$ sqlite db
> create table addressbook(name,address,csz,phone);
> insert into addressbook values("Robert","123 Third","90210","123-555-1234");
> select * from addressbook;
> .exit

Next install php.tar.gz via the mydsl system.
Then start Monkey

Then in /opt/monkey/htdocs make a simple test.php
<?
require "sqlite.php"
$db = "/home/dsl/db";
sqlite_connect($db) or die("Count not connect to database");
$query = "select * from addressbook";
$myResult = sqlite_query($query,$db) or die("Query Failed");
$myRow = sqlite_fetch_array($myResult);
$name = $myRow["name"];
?>
<HTML>
<title>Test Sqlite Interface</title>
<body>
<? print $name; ?>
</body>
</html>

Have Fun. If you improve my library, please let me know.

Next Page...
original here.