MySQLi 用のカスタム クラスを作成しようとしていますが、num_rows
. 誰でも助けることができますか?
class db {
private $host = "***";
private $user = "***";
private $pass = "***";
private $database;
private $connection;
private $result;
public $sql;
function __construct($database) {
if (!empty($database)) $this->database = $database;
$this->connection = new mysqli($this->host,$this->user,$this->pass,$this->database);
return $this->connection;
}
public function fetchRowNum($sql) {
if (!empty($sql)) {
$this->sql = $sql;
return $this->connection->query($sql)->num_rows;
} else {
throw new Exception("Error fetching row");
}
}
}