我正在尝试从 mysql 转换为使用 PDO。我被困在这个错误上。在大多数情况下,我让它工作,除了绑定变量。
Fatal error: Call to a member function bindParam() on a non-object in
这是我尝试过的:
global $keyword;
$_link = new PDO("mysql:host=$host;dbname=$db_name", "$username", "$password");
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM PLD_ANINJA WHERE `Text` REGEXP CONCAT('[[:<:]]',:keyword,'[[:>:]]') LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
$_query->bindParam(':keyword',$keyword, PDO::PARAM_STR);
$_query->execute();
这是最初的工作:
global $keyword;
$_query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM PLD_ANINJA WHERE `Text` REGEXP '[[:<:]]" . $keyword . "[[:>:]]' LIMIT %d,%d",
SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());