0

I am using this method to fetching the Rows from the database and showing on the frontend but when it execute it is giving a fatel error that is

Fatal error: Call to a member function getRow() on a non-object in D:\xampp\htdocs\Deshbandhu\class\tblOp.php on line 432

and the function code which I am using that is

 function getRowFields($fields,$where = NULL, $order = NULL){
    global $db; 
    $fields = ($fields) ? " $fields "           : " * ";
    $where  = ($where) ? " WHERE $where "       : "";
    $order  = ($order) ? " ORDER BY $order "    : " ORDER BY {$this->primaryKey} ";
    $sql    = "SELECT $fields FROM {$this->table} $where $order;"; // limit 0,1
    $res    =$db ->getRow($sql, DB_FETCHMODE_ASSOC);
    echo $res; exit;
    if (DB::isError($res))
        return $this->raiseError($res);
    return $res;
}

and the defination of the getRow() are

function getRow($where = NULL, $order = NULL,$fields=NULL){
    global $db; 

   $sql    = $this->buildQuery(NULL, TBLOP_EXECUTE_SELECT, $where, $order,$fields);

    //echo $sql.'<br>';
    $res    = $db->getRow($sql, DB_FETCHMODE_ASSOC);

    if (DB::isError($res))
        return $this->raiseError($res);

    return $res;
}

this code is running on live server and not giving any error but when I execute it on local server it is showing error like this.

4

3 回答 3

0

对我来说看起来像 AdoDB,我使用的是相同的。您忘记了数据库设置吗?看起来应该是这样的:

$db = ADONewConnection("mysql"); // eg 'mysql' or 'postgres'
$db->Connect("host", "user", "password", "table");
于 2013-10-25T06:01:13.340 回答
0

问题在于您的$db变量,检查您的数据库初始化代码,它可能无法连接到数据库并且没有检查错误。

于 2013-10-25T05:53:35.007 回答
0

我以前遇到过这个问题,我通过修复我的表来解决它。

于 2016-02-26T18:37:14.313 回答