在PHP中保存功能

时间:2015-03-03 06:34:13

标签: php mysqli

我正在编辑问题:::我的保存功能出了什么问题。它在save方法的第二行中给出了“对非对象错误调用成员函数bind_param()”。

public function __construct()
{   
$this->lastResult=null;
global $loader;
$this->_dbConfig = $loader->getConfig('database');

if(Env == 'development')

{
    $dbcon=$this->_dbConfig['local'];

}
else
{
    $dbcon=$this->_dbConfig['global'];

}
$con=mysqli_connect($dbcon['servername'],       $dbcon['username'],$dbcon['password'],$dbcon['databasename']);

$this->mysqli=$con;
if (mysqli_connect_errno())
{
throw new Exception("Failed to connect to MySQL: " . mysqli_connect_error(), 1);
}
}
                                                                       //This is my save method for inserting value dynamically
public function save($data,$data1)
{ 
$insert=$this->mysqli->prepare("insert into $this->tbl1(test1,test2)      values (?,?)");//giving error in this line.
$insert->bind_param('is',$data,$data1);
$insert->execute();
$insert->close();

}

0 个答案:

没有答案