PHP OOP issue with database

前端 未结 3 1891
清歌不尽
清歌不尽 2021-01-26 17:43

I am querying usernames from database using the get() function in the DB class.. its always returning \'No users\' even if there are users existing in the database.. here is my

相关标签:
3条回答
  • 2021-01-26 18:01

    Please look at this answer Row count with PDO

    PDO has PDOStatement::rowCount(), which apparently does not work in MySql. What a pain.

    0 讨论(0)
  • 2021-01-26 18:08

    In your query function when binding you do:

    foreach ($params as $param) {
        $this->_query->bindValue($x, $params);
        $x++;
    }
    

    You are binding $params which is an array, not the value. Change $params to $param (singular) and it will likely work.

    0 讨论(0)
  • 2021-01-26 18:13

    Try changing

    $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?";
    

    to

    $sql = "{$action} FROM {$table} WHERE {$field} {$operator} {$value}";
    
    0 讨论(0)
提交回复
热议问题