2015-04-12 259 views
-2

我與MySQL功能簡單MYSQL到PDO函數調用一個成員函數查詢()一個非對象

function sanatciver($id,$deger){ 
$result=mysql_query("select $deger from sanatci where sanatcino=$id"); 
$row=mysql_fetch_assoc($result); 
return $row["$deger"]; 
} 

與PDO

$records = $db->select('mp3no, sanatcino')->from('mp3')->where('sanatcino', '=', $sno)->where('onay', '=', 1)->orderBy('mp3no', 'desc')->getAll(); 
$adet=$db->count(); 
foreach($records as $record) { 
$mp3no    = $record->mp3no; 
$sanatcino    = $record->sanatcino; 

即時通訊新用戶是我的樣本頁面查詢成功運行。

,但我想是寫簡單的功能,它在非對象上做出錯誤調用一個成員函數查詢()

我的樣本函數

function sanatciver($id,$deger){ 
$result = $db->select('$deger')->from('sanatci')->where('sanatcino', '=', $id)->get(); 
$xx    = $result->$deger; 
return $xx; 
} 

但其製作錯誤,怎麼能我做 ?

回答

-1

使用全局

function sanatciver($id,$deger){ 
    global $db; 
    $result = $db->select('$deger')->from('sanatci')->where('sanatcino', '=', $id)->get(); 
    $xx    = $result->$deger; 
    return $xx; 
    } 
+0

感謝我知道這個選擇,但我的其他查詢出毛病。在我的主頁上打印其他頁面已損壞 – sinan

相關問題