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)
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?