A super easy PHP Framework for web development!
https://github.com/exacti/phacil-framework
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
2.4 KiB
140 lines
2.4 KiB
2 years ago
|
<?php
|
||
|
/**
|
||
|
* Copyright © 2023 ExacTI Technology Solutions. All rights reserved.
|
||
|
* GPLv3 General License.
|
||
|
* https://exacti.com.br
|
||
|
* Phacil PHP Framework - https://github.com/exacti/phacil-framework
|
||
|
*/
|
||
|
|
||
|
namespace Phacil\Framework\Databases\Object;
|
||
|
|
||
|
use Phacil\Framework\Databases\Object\ResultInterface;
|
||
2 years ago
|
use SplObjectStorage;
|
||
2 years ago
|
|
||
1 year ago
|
if (version_compare(phpversion(), "7.1.0", ">=")) {
|
||
|
class ComplementResult extends \Phacil\Framework\Databases\Object\Aux\ComplementResult
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
class ComplementResult extends \Phacil\Framework\Databases\Object\Aux\ComplementResultLegacy{
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class Result extends ComplementResult implements ResultInterface {
|
||
2 years ago
|
|
||
|
/**
|
||
|
*
|
||
|
* @var array
|
||
|
*/
|
||
|
public $rows;
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @var array
|
||
|
*/
|
||
|
public $row;
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @var int
|
||
|
*/
|
||
|
public $num_rows;
|
||
|
|
||
2 years ago
|
/**
|
||
|
*
|
||
|
* @var \Phacil\Framework\Databases\Object\Item[]|\SplObjectStorage|\Iterator|null
|
||
|
*/
|
||
|
public $data = null;
|
||
|
|
||
2 years ago
|
/**
|
||
|
*
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getData($numRow = false) {
|
||
|
return $numRow ? $this->getRow($numRow) : $this->getRows();
|
||
|
}
|
||
|
|
||
2 years ago
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getItems() {
|
||
|
return $this->__toObject();
|
||
|
}
|
||
|
|
||
2 years ago
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function setRows($rows){
|
||
|
$this->rows = $rows;
|
||
11 months ago
|
$this->row = isset($rows[0]) ? $this->rows[0] : null;
|
||
2 years ago
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getRows(){
|
||
|
return $this->rows;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function setRow($row){
|
||
|
$this->row = $row;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getRow($numRow = false){
|
||
1 year ago
|
return $numRow ? (isset($this->rows[$numRow + 1])?$this->rows[$numRow + 1] : null ) : $this->row;
|
||
2 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function setNumRows($num){
|
||
|
$this->num_rows = $num;
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function getNumRows(){
|
||
|
return $this->num_rows;
|
||
|
}
|
||
2 years ago
|
|
||
|
/**
|
||
|
* {@inheritdoc}
|
||
|
*/
|
||
|
public function __toObject() {
|
||
|
return $this->data ? $this->data : $this->loop($this->rows);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @param mixed $array
|
||
|
* @return \Phacil\Framework\Databases\Object\ItemInterface[]
|
||
|
*/
|
||
|
protected function loop($array)
|
||
|
{
|
||
|
if($this->data) return $this->data;
|
||
|
|
||
|
$this->data = new SplObjectStorage();
|
||
|
foreach ($array as $key => $value) {
|
||
|
//$this->data[] = new \Phacil\Framework\Databases\Object\Item($value);
|
||
|
$obj = new \Phacil\Framework\Databases\Object\Item();
|
||
|
$this->data->attach($obj->setData($value));
|
||
|
}
|
||
|
|
||
|
return $this->data;
|
||
|
}
|
||
2 years ago
|
|
||
|
}
|