Finding and fetching

Finding and fetching --  Simple Querying methods ::staticGet() ::get() ::find() ::fetch() ::count()

::get()

Simple Get (Select) request, are achieved using the get method

::get (mixed Key or Value [, mixed Value])

The basic get method for an extended class can be used in two ways, to get based on the primary key (one parameter) or based on a key and value (two parameters)

This would execute the following SQL statement and fetch the results into the objects variables

To use another field other than the primary key, you would use it with two parameters

This would execute the following SQL statement and fetch the results into the objects variables

The result of these two queries would be that all the objects variables would contain the matched row's data and the variable $person->N would contain the number of matches.

::staticGet()

Simple Get (Select) request, abbreviated get request.

::staticGet (mixed Key or Value [, mixed Value])

The static method is similar to the get request, however it does not require the initial instantiation of the class. staticGet also caches the result.

You may also use the DB_DataObject staticGet method directly, however you need to specify which class you wish to use. In this case, the Class file will be automatically loaded.

::find()

Searching for Items

integer ::find ([boolean AutoFetch])

The find method builds and executes the current Query, based on the object variables and any 'WhereAdd' conditions , If the AutoFetch is TRUE, then it will also call the fetch method automatically.

This would execute the following SQL statement and fetch the results into the objects variables

::fetch()

Getting the data.

boolean ::fetch ()

The fetch method gets the next row and sets the objects variables to the rows data. It returns true if data has been collected, and false when there is no more data.

::count()

Performs a select count() request

int ::count ()

Performs a select count() request on the tables key column, and returns the number of rows returned

This would execute the following SQL statement and fetch the results into the objects variables