Jon Slack - 2006-10-20 00:21:37 -
In reply to message 1 from Harvey A. Ramer
You said:
"I am working on a music label project where the same architecture and MySQL database will be reused. I hope there is a way I can filter results from the dataset in the db object on a field in the MySQL database. Then I could use the db object just as before without worrying about filtering each sql query on that field."
I *think* I know what you're trying to do.
If you use:
$rows = $db->get_results("SELECT * FROM mysqltable)
then $rows is an array with each element containing a row from the table and you get at the data by using $variable = $row[key]->mysqlfieldname
if you use:
$db->get_results("SELECT * FROM mysqltable)
you can then use
$row = $db->get_row(null, rownumber) (rownumber = 0 to numrecords - 1)
This gets the result from the array of results stored in an array called last_result used within the ez_sql file.
Similarly you can use $db->get_var, $db->$get_col etc using null as a query (with the offset[s]) to access the last set of results.
I cannot see any way of producing a subset of results from the buffer based on search criteria because $db->get_results, when used with a null query will always return the full set. You would have to use a normal foreach loop (or array function[s]) to filter the data. It may be quicker just to requery the database by specifying the SELECT statement but note that if you requery the MySQL tables, the buffer will only contain the results of the most recent query; that is, the subset of data you asked for.
If this is NOT what you're looking for, then sorry - but at least writing it all out helped clarify it it MY mind. Let me know...