|
Posted by Stefan Rybacki on 10/30/05 15:02
Oli Filth wrote:
> Zsolt Munoz said the following on 30/10/2005 02:11:
>
>> I am pretty new to OOP w/PHP but I feel that it may be in my best
>> interest to learn it. I have created a class to connect to a MySQL DB
>> but when I go to run a query I only get the 1st row from table and
>> cannot get anything else. Below is the class I created and how I am
>> executing the program. Maybe someone could give me a hand with this.
>>
> <...snip code...>
>
> From a quick perusal of your code, it appears that you're opening and
> closing the MySQL connection on every function call...
>
Yes this is one point, but what he also is doing is
calling $db->result(), $db->result calles $db->query() and returns the first row. The next
time you call $db->result() you do the query again and again and again.
Rethink your class.
- only connect once (maybe in the constructor or the when the first query should be
executed -> save the connection for later use and check for its existence
Regards
Stefan
Navigation:
[Reply to this message]
|