I have a question about some functions of MySQLi
In the conventional way we would do this:
public function Numrows($sql) {
return mysqli_num_rows($sql);
}
And since I'm using extends mysqli
I'm doing this:
public function dbNumRows($Query) {
$sql = parent::prepare($Query);
return $sql->num_rows();
}
What is the most correct way to return line numbers using PHP Oriented with class extends mysqli
?
Full class connection
<?php
class Connect extends mysqli {
public $db_connection, $db_hostname, $db_username, $db_password, $db_database;
public function __construct() {
$this->db_hostname = DB_HOSTNAME;
$this->db_username = DB_USERNAME;
$this->db_password = DB_PASSWORD;
$this->db_database = DB_DATABASE;
$this->connectMe();
}
private function connectMe() {
$this->db_connection = @$this->connect($this->db_hostname, $this->db_username, $this->db_password, $this->db_database);
if ($this->connect_error) {
die("Falha na tentativa de se conectar com o servidor: " . $this->connect_error);
}
}
public function dbExecute($Query) {
$Result = $this->query($Query);
if ($this->error) {
die("Erro no comando: $Query");
}
return $Result;
}
public function dbNumRows($Query) {
return $this->prepare($Query)->num_rows();
}
}
Att.