flatfile
[ class tree: flatfile ] [ index: flatfile ] [ all elements ]

Class: Flatfile

Source Location: /flatfile.php

Class Overview


Implements simple but powerful flat file database storage and retrieval


Variables

Methods



Class Details

[line 61]
Implements simple but powerful flat file database storage and retrieval

Includes equivalents to SELECT * FROM table WHERE..., DELETE WHERE ... UPDATE and more. All files are stored in the $datadir directory, and table names are just filenames in that directory. Subdirectories can be used just by specifying a table name that includes the directory name.




[ Top ]


Class Variables

$datadir =

[line 66]

The directory to store files in.


Type:   mixed


[ Top ]



Class Methods


method deleteAll [line 265]

void deleteAll( string $tablename)

Delete all rows in a table



Parameters:

string   $tablename   The table to update

[ Top ]

method deleteWhere [line 246]

void deleteWhere( string $tablename, mixed $whereClause, object $whereClause.)

Deletes all rows in a table that match specified criteria



Parameters:

string   $tablename   The table to update
object   $whereClause.   WhereClause object that will select rows to be deleted. All rows are deleted if $whereClause === NULL

[ Top ]

method insert [line 184]

void insert( string $tablename, array $newRow)

Inserts a row in a table



Parameters:

string   $tablename   The table to insert data into
array   $newRow   The new row to add to the table

[ Top ]

method insertWithAutoId [line 163]

int insertWithAutoId( string $tablename, int $idField, array $newRow)

Inserts a row with an automatically generated ID

The autogenerated ID will be the highest ID in the column so far plus one.




Tags:

return:  The newly assigned ID


Parameters:

string   $tablename   The table to insert data into
int   $idField   The index of the field which is the ID field
array   $newRow   The new row to add to the table

[ Top ]

method selectAll [line 73]

array selectAll( string $tablename)

Get all rows from a table



Tags:

return:  The table as an array of rows, where each row is an array of columns


Parameters:

string   $tablename   The table to get rows from

[ Top ]

method selectUnique [line 143]

array selectUnique( string $tablename, string $idField, string $id)

Select a row using a unique ID



Tags:

return:  The row of the table as an array


Parameters:

string   $tablename   The table to get data from
string   $idField   The index of the field containing the ID
string   $id   The ID to search for

[ Top ]

method selectWhere [line 99]

array selectWhere( string $tablename, object $whereClause, [mixed $limit = -1], [mixed $orderBy = NULL])

Selects rows from a table that match the specified criteria

This simulates the following SQL query:

   SELECT TOP $limit * FROM  $tablename
   WHERE $whereclause
   ORDER BY $orderByField $orderByType




Tags:

return:  The matching data, as an array of rows, where each row is an array of columns


Parameters:

string   $tablename   The table (file) to get the data from
object   $whereClause   Either a WhereClause object to do selection of rows, or NULL to select all
mixed   $limit   Specifies limits for the rows returned:
  • use -1 or omitted to return all rows
  • use an integer n to return the first n rows
  • use a two item array ($startrow, $endrow) to return rows $startrow to $endrow - 1 (zero indexed)
  • use a two item array ($startrow, -1) to return rows $startrow to the end (zero indexed)
mixed   $orderBy   Either an OrderBy object or an array of them, defining the sorting that should be applied (if an array, then the first object in the array is the first key to sort on etc). Use NULL for no sorting.

[ Top ]

method updateRowById [line 200]

void updateRowById( string $tablename, int $idField, array $updatedRow)

Updates an existing row using a unique ID



Parameters:

string   $tablename   The table to update
int   $idField   The index of the field which is the ID field
array   $updatedRow   The updated row to add to the table

[ Top ]

method updateSetWhere [line 223]

void updateSetWhere( string $tablename, array $newFields, WhereClause $whereClause)

Updates fields in a table for rows that match the provided criteria

$newFields can be a complete row or it can be a sparsely populated hashtable of values (where the keys are integers which are the column indexes to update)




Parameters:

string   $tablename   The table to update
array   $newFields   A hashtable (with integer keys) of fields to update
WhereClause   $whereClause   The criteria or NULL to update all rows

[ Top ]


Documentation generated on Sat, 5 Mar 2005 02:26:25 +0000 by phpDocumentor 1.3.0RC3