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 226]

void deleteAll( string $tablename)

Delete all rows in a table



Parameters:

string   $tablename   The table to update

[ Top ]

method deleteWhere [line 208]

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 173]

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 152]

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 132]

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 96]

array selectWhere( string $tablename, object $whereclause, [int $limit = -1], [int $orderByField = -1], [int $orderByType = ASCENDING])

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
int   $limit   The max number of rows to return or -1 for all
int   $orderByField   The index (in the table row array) of the field to sort by (or -1 to omit the ORDER BY clause)
int   $orderByType   Either ASCENDING or DESCENDING (ignored if $orderByField == -1)

[ Top ]

method updateRowById [line 189]

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 ]


Documentation generated on Mon, 28 Feb 2005 23:04:36 +0000 by phpDocumentor 1.3.0RC3