Back to Littlefoot Manual

The database object is a singleton. You can pull the instance as follows:

$db = db::init();

The first time this is called, a new database instance will be created. After that, the old object is simply returned. If you are in the littlefoot context, this is already likely accessible at $this->db

sqlresult query('SELECT * FROM table')

Run query, return SQL result, increment SQL counter

array fetch('SELECT * FROM table')

Run query and return first row returned as an array. Increment SQL counter.

array fetchall('SELECT * FROM table')

Run query and return matrix array of the rows:

  0 => array(id => 1, col1 => 'valA', col2 => 'val1', ...), 
  1 => array(id => 2, col1 => 'valB', col2 => 'val2', ...)

void import($file)

SQL commands are preg_match()'d out of $file and run in a loop with errors suppressed

void dump($table = '', $folder = NULL)

$folder is the destination, $table will print only the table instead of the whole database

string escape($string)

$string is usually user-supplied supplied data. Don't forget to sanatize input!

You can read more things about the db class in the PHP Doc

Now for the ORM

blog comments powered by Disqus