开发者

Unable to query local database Query was empty

I'm in the process of refactoring my DAL and I will now start using mysqli and prepared statements. My first task is to use mysqli so I'm testing this now.

This is my DAL class. This is just part of the code I use:

class DAL {
  private $mysqli;
  (...)

  // Create new mysqli object
  private function conn() {
    $this->mysqli = new mysqli($this->host, $this->username, $this->pwd, $this->dbname);
    if(mysqli_connect_errno()) {
          echo "Connection Failed: " . mysqli_connect_errno(); exit();
    }    
  } 

  public function getRowByValue($table,$column, $value)
  {   
    $this->conn(); 
    $result = $this->mysqli->query("SELECT name FROM sl_store LIMIT 5");
    $result->close();
}

When executing the mysqli query, I only get this result: Unable to query local database Query was empty. I'v开发者_如何学JAVAe tested the SQL code in Toad and it returns 5 rows.

So why am I getting this error / what am I doing wrong?


even if no processing on your query is needed (no variable interpretation etc.) it could be possible, that query() needs a string delimited with " instead of '. Just a guess because of this example from php.net

if (!$mysqli->query("SET @a:='this will not work'")) {
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜