I have one table and I need to read records of this table but with one query and where I want to recod number one just I put one function.
(i think I need one class)
One query for all?
Started by Hamed, Jul 07 2010 03:18 AM
2 replies to this topic
#1
Posted 07 July 2010 - 03:18 AM
|
|
|
#2
Posted 07 July 2010 - 04:57 AM
public function get($tname)
{
global $db;
$query = $db->query("SELECT * FROM `templates` WHERE sid='{$this->sid}' AND `tname`='{$tname}' LIMIT 1;");
if($db->num_rows($query) != '0')
{
$t = $db->fetch_array($query);
$tname = $t['tname'];
$codes = $this->replace($t['codes']);
//$codes = "<!-- start: $tname : {$this->sid} -->\n{$codes}\n<!-- end: $tname : {$this->sid} -->";
$codes = str_replace("\\'", "'", addslashes($codes));
return $codes;
}
else
{
die("TPLClass:We do not have ".$tname." in our templates table.!");
}
}
Look I use this function to read my template code, when I read one template i will have one more query Now I want to read all templates at the 1st time and after that I use another function to read one of them??It is possible?
#3
Posted 07 July 2010 - 01:15 PM
easiest is to fetch all and store the one you're looking for with further use
i.e no where and no limiting and fetch them in a while loop instead.
i.e no where and no limiting and fetch them in a while loop instead.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall


Sign In
Create Account


Back to top









