DIGITEC-314 Ошибка скрипта импорта

Создан интерфейс для классов SqlResultProvider и SqlResultCollection. В последний добавлены недостающие метода
This commit is contained in:
Alexander Demidov
2014-03-13 12:39:44 +04:00
parent 6b0bf4058e
commit 5f9c295c01
3 changed files with 51 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
class SqlResultCollection extends ArrayIterator class SqlResultCollection extends ArrayIterator implements iSqlResultItems
{ {
private $items; private $items;
@ -12,8 +12,29 @@ class SqlResultCollection extends ArrayIterator
} }
} }
/**
* @return DbStatement[]
*/
public function fetchAll() public function fetchAll()
{ {
return $this->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);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
class SqlResultProvider class SqlResultProvider implements iSqlResultItems
{ {
/** /**
* @var DbStatement * @var DbStatement
@ -77,15 +77,6 @@ class SqlResultProvider
} }
/** /**
* @return DbStatement[]|SqlResultCollection[]
*/
public function fetchAll()
{
$this->defineResultItems();
return $this->result_items;
}
/**
* @param $key * @param $key
* @return mixed * @return mixed
* метод актуален после вызова assoc * метод актуален после вызова assoc
@ -96,6 +87,15 @@ class SqlResultProvider
} }
/** /**
* @return DbStatement[]|SqlResultCollection[]
*/
public function fetchAll()
{
$this->defineResultItems();
return $this->result_items;
}
/**
* @param $field * @param $field
* @return mixed * @return mixed
*/ */
@ -104,11 +104,17 @@ class SqlResultProvider
return $this->result->fetchField($field); 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() public function affectedRows()
{ {
return $this->result->affectedRows(); return $this->result->affectedRows();

10
model/iSqlResultItems.php Normal file
View File

@ -0,0 +1,10 @@
<?php
interface iSqlResultItems
{
public function fetchAll();
public function fetchField($field);
public function fetch();
}