I've come up with two classes:
Db_Connection - This handles the connection to the database
Db_Query - This handles the querying and results
The idea is that I have one Db_Connection object which when I use the query method it returns a Db_Query object.
The query method is something like:
Code: Select all
<?php
function &query($query) {
$result =& new Db_Query($this->connection, $query);
return $result;
}
?>Code: Select all
<?php
$result =& $db->query("SELECT * FROM Blah");
?>I want to make sure that the query object is only created once and not copied when being returned.
According to (my understanding of) the PHP manual this should do what I want it to, but it's very difficult for me to work out if it actually is!!
Any comments would be greatly appreciated!