古いmysqlインターフェースは常に十分であったため、phpで新しいmysqliクラスを使用したことはありませんが、mysqliを使用するように古いコードを更新しようとしていますが、うまくいかず、次のエラーが発生します。
[error] [client 127.0.0.1] PHP Fatal error: Call to a member function fetch_row() on a non-object in [location of file]
ただし、クエリをエコーしてデータベースで直接使用すると、良い結果が得られるため、クエリが適切であることがわかります。「fetch_row()」を間違って使用しているような気がします。
誰かが私が間違っていることを提案できますか?
/// class setup stuff
public function query($query,$sanitize=TRUE)
{
if($sanitize!==FALSE)
{
$query=$this->mysqli->escape_string($query);
}
echo $query;
$this->mysqli->query($query);
echo $this->mysqli->error;
//$this->mysqli->free();
}
public function select($table,$what,$where,$orderby=FALSE,$order=FALSE,$limits=FALSE,$sanitize=TRUE) //this is really simple and very limited
{
//process the select query and send to query method
$query = "SELECT $what FROM $table WHERE ";
$i = 0;
foreach($where as $key => $value)
{
$key = $sanitize?$this->mysqli->escape_string($key):$key;
$value = $sanitize?$this->mysqli->escape_string($value):$value;
$query .= "$key='$value' ";
$i++;
if($i<count($where))
{
$query .= "AND ";
}
}
// check the max rowcount
$this->query($query,FALSE);
$result = $this->mysqli->use_result(); //<--this is the issue