Re: MySQL Problem



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 .



Relevant Pages

  • Re: Problem with SQL and Recordset
    ... This assumes that the name of the subform control on the parent form is the ... NextSuffix field from the "query" to be entered into the Suffix field on ... Dim mySQL As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: [Q]Problems related to the MySQL linked Server.
    ... The error messge when I query data with following SQL. ... select @v_intUserNo = uno ... where userid = 'testid' ... I have two questions about the linked server for the MySQL. ...
    (microsoft.public.sqlserver.odbc)
  • Re: Performance MySQL
    ... schicke erst den Query an die Datenbank ab, ... Möglichkeit von Concurrent Inserts nur MyISAM Storages ein. ... > MySQL bis jetzt noch nichts zu bieten. ... Welcher Tabellentyp? ...
    (de.comp.datenbanken.mysql)
  • Re: where to get mySQL questions answered?
    ... After resolving some performance issues with mysql in building initial ... soon as I add an OR to my WHERE x LIKE '%blah%' type queries. ... My php code dynamically builds an sql query. ...
    (comp.lang.php)
  • Re: MySQL Performance
    ... Try enabling slow query logging, as well as maybe try to isolate if the ... load is coming from any particular query... ... > MySQL server seems to run fine as long as I watch it, ... > to 97% CPU usage. ...
    (freebsd-isp)