Public functions GetName () { $sql =sprintf ("Select pin,point from table"); $results = Array (); if (! $error = $this->db->query ($sql)) { $name = $this->getsn ($results [' pin ']); $this->hlist[] = $results; } $this->db->free (); $this->db2->free (); return $this->hlist;} Public Function GETSN ($pin) { $sql = sprintf ("Select sn from '%s_pin ' WHERE pin=%s ', __mysql_prefix, $pin); return $this->db2->get_one ($sql);}
Execute another SQL during SQL execution. The original GETSN in the DB2 is written in db, but found that the data only 1, so add a DB2
Now SQL is no problem, but open the page for a long time, ask how to optimize??
Reply to discussion (solution)
$this->db2-> Get_one ($sql)
From the name of the method, it is to take a record
$this->db2-> Get_one ($sql)
From the name of the method, it is to take a record
Table
Series (data sheet): ID (field) name
Category:id Seriesid Name
$sql =sprintf ("Select Id,seriesid,name from category"); if (! $error = $this->db->query ($sql)) { $name = $this->getname ($results [' seriesid ']); $results [' Seriesid ']= $name [' name ']; $this->hlist[] = $results; } Return $this->hlist;//I want to replace the SERIESID from the category table with the corresponding name//But in this way, when the page is opened to wait a long time, how can I optimize?? function GetName ($seriesid) { $sql =sprintf ("Select name from series where id= $seriesid"); return $this->db2->get_one ($sql);}
Are you sure that the page is slow is a problem with this code?
Check yourself first to see where it is slow.