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 @@ +