Browse Source

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

Создан интерфейс для классов SqlResultProvider и SqlResultCollection. В последний добавлены недостающие метода
namespace
Alexander Demidov 11 years ago
parent
commit
5f9c295c01
  1. 25
      model/SqlResultCollection.php
  2. 30
      model/SqlResultProvider.php
  3. 10
      model/iSqlResultItems.php

25
model/SqlResultCollection.php

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

30
model/SqlResultProvider.php

@ -1,6 +1,6 @@
<?php
class SqlResultProvider
class SqlResultProvider implements iSqlResultItems
{
/**
* @var DbStatement
@ -77,15 +77,6 @@ class SqlResultProvider
}
/**
* @return DbStatement[]|SqlResultCollection[]
*/
public function fetchAll()
{
$this->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();

10
model/iSqlResultItems.php

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