php - How to make a function for autoset -


i'm not sure if possible or not looking way making auto "set" mysql results.

function test(){         $pdatabase = database::getinstance();         $site = new template("sites.tpl");         $query = 'select * sites';         $result = $pdatabase->query($query) or die('query failed: ' . mysql_error());         while ($row = mysql_fetch_array($result)) {             $site->set("id",$row['id']);             $site->set("category",$row['category']);             $site->set("name",$row['name']);             $site->set("html",$row['html']);             $site->set("css",$row['css']);             $site->set("js",$row['js']);             $site->set("php",$row['php']);             $site->set("details",$row['details']);             $site->set("link",$row['link']);         }         mysql_free_result($result);      } 

maybe there better way doing $site->set ? mean code looks way big , pointless. other ways ?

if want call $site->set on key/value pairs in $row

while ($row = mysql_fetch_array($result)) {     foreach($row $key => $value) {         $site->set($key,$value);     } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -