From a52e24ae450ff6510699a860062a760bb3de60c4 Mon Sep 17 00:00:00 2001 From: Igor V Belousov Date: Wed, 25 Jan 2017 20:48:32 +0300 Subject: [PATCH] count --- frm/Model.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frm/Model.php b/frm/Model.php index d3b0d40..756d51f 100644 --- a/frm/Model.php +++ b/frm/Model.php @@ -97,4 +97,13 @@ class Model { } return false; } + + public function count() { + $child_model_name = get_called_class(); + $model = new $child_model_name; + $stmt = $this->app->dbh->prepare( 'SELECT count(id) FROM ' . $model->_table_name ); + $model = null; + $stmt->execute(); + return (int) $stmt->fetchColumn(); + } } \ No newline at end of file