From 5f9c295c01ca57a7b32b19b99314d4be1cc8cffe Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Thu, 13 Mar 2014 12:39:44 +0400 Subject: [PATCH] =?UTF-8?q?DIGITEC-314=20=D0=9E=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=BF=D0=BE=D1=80=D1=82=D0=B0=20=D0=A1=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9?= =?UTF-8?q?=D1=81=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D0=BE=D0=B2=20SqlResultProvider=20=D0=B8=20SqlResultCollection?= =?UTF-8?q?.=20=D0=92=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=81=D1=82=D0=B0=D1=8E=D1=89=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/SqlResultCollection.php | 25 +++++++++++++++++++++++-- model/SqlResultProvider.php | 30 ++++++++++++++++++------------ model/iSqlResultItems.php | 10 ++++++++++ 3 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 model/iSqlResultItems.php diff --git a/model/SqlResultCollection.php b/model/SqlResultCollection.php index 0d8a74d..11da844 100644 --- a/model/SqlResultCollection.php +++ b/model/SqlResultCollection.php @@ -1,6 +1,6 @@ items; + return (array) $this; + } + + /** + * @param $field + * @return mixed + */ + public function fetchField($field) + { + $item = $this->offsetGet(0); + return $item->{$field}; + } + + /** + * @return mixed + */ + public function fetch() + { + return $this->offsetGet(0); } } \ No newline at end of file diff --git a/model/SqlResultProvider.php b/model/SqlResultProvider.php index a9081dc..9ec9048 100644 --- a/model/SqlResultProvider.php +++ b/model/SqlResultProvider.php @@ -1,6 +1,6 @@ defineResultItems(); - return $this->result_items; - } - - /** * @param $key * @return mixed * метод актуален после вызова assoc @@ -96,6 +87,15 @@ class SqlResultProvider } /** + * @return DbStatement[]|SqlResultCollection[] + */ + public function fetchAll() + { + $this->defineResultItems(); + return $this->result_items; + } + + /** * @param $field * @return mixed */ @@ -104,11 +104,17 @@ class SqlResultProvider return $this->result->fetchField($field); } - public function fetch($style = Db::FETCH_OBJ) + /** + * @return mixed + */ + public function fetch() { - return $this->result->fetch($style); + return $this->result->fetch(Db::FETCH_OBJ); } + /** + * @return int + */ public function affectedRows() { return $this->result->affectedRows(); diff --git a/model/iSqlResultItems.php b/model/iSqlResultItems.php new file mode 100644 index 0000000..4e0ef72 --- /dev/null +++ b/model/iSqlResultItems.php @@ -0,0 +1,10 @@ +