Commit 8657c792 authored by Alex Ne's avatar Alex Ne

PDO add Count()

parent ffaf2bd2
......@@ -233,6 +233,24 @@ class PDO {
return $statement->execute();
}
/**
* @param $table
* @param $where
* @param $column
*/
public function count($table, $where, $column = "*") {
$whete_obj = new PDOWhereConstructor($where);
$SQL = "SELECT count({$column}) FROM `{$table}` {$whete_obj->get_sql()}";
$statement = $this->prepare($SQL);
$whete_obj->bind($statement);
$statement->execute();
if ($statement->rowCount() > 0) {
return $statement->fetchAll(\PDO::FETCH_ASSOC)[0]["count({$column})"];
} else {
return false;
}
}
/**
* @param $table
* @param array $where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment