PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
Simple Get (Select) request, are achieved using the get method
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)
Beispiel 1. Simple fetch of data based on Primary Key
|
This would execute the following SQL statement and fetch the results into the objects variables
Beispiel 2. Resulting SQL
|
To use another field other than the primary key, you would use it with two parameters
Beispiel 3. Simple fetch of data based on Key and Value
|
This would execute the following SQL statement and fetch the results into the objects variables
Beispiel 4. Resulting SQL
|
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.
Beispiel 5. Results of example code
|
Simple Get (Select) request, abbreviated get request.
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.
Beispiel 6. Simple fetch of data based on Primary Key
|
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.
Beispiel 7. Simple fetch of data based on Primary Key
|
Searching for Items
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.
Beispiel 8. Simple find of data based on Object Vars
|
This would execute the following SQL statement and fetch the results into the objects variables
Beispiel 9. Resulting SQL
|
Getting the data.
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.
Beispiel 10. Simple find and fetch of data based on Object Vars
|
Performs a select count() request
Performs a select count() request on the tables key column, and returns the number of rows returned
Beispiel 11. Simple find and fetch of data based on Object Vars
|
This would execute the following SQL statement and fetch the results into the objects variables
Beispiel 12. Resulting SQL
|
Zurück | Zum Anfang | Nach vorne |
Auto Building | Nach oben | Modifying the database |