Begin Refactor

This commit is contained in:
color.diff=auto
2021-03-21 13:47:29 -06:00
parent 7622dc0d02
commit 018931d7ae
197 changed files with 47799 additions and 6 deletions

View File

@@ -0,0 +1,48 @@
<?php
namespace RedBeanPHP\Cursor;
use RedBeanPHP\Cursor as Cursor;
/**
* NULL Database Cursor
* Implementation of the NULL Cursor.
* Used for an empty BeanCollection. This Cursor
* can be used for instance if a query fails but the interface
* demands a cursor to be returned.
*
* @file RedBeanPHP/Cursor/NULLCursor.php
* @author Gabor de Mooij and the RedBeanPHP Community
* @license BSD/GPLv2
*
* @copyright
* (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
* This source file is subject to the BSD/GPLv2 License that is bundled
* with this source code in the file license.txt.
*/
class NullCursor implements Cursor
{
/**
* @see Cursor::getNextItem
*/
public function getNextItem()
{
return NULL;
}
/**
* @see Cursor::reset
*/
public function reset()
{
return NULL;
}
/**
* @see Cursor::close
*/
public function close()
{
return NULL;
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace RedBeanPHP\Cursor;
use RedBeanPHP\Cursor as Cursor;
/**
* PDO Database Cursor
* Implementation of PDO Database Cursor.
* Used by the BeanCollection to fetch one bean at a time.
* The PDO Cursor is used by Query Writers to support retrieval
* of large bean collections. For instance, this class is used to
* implement the findCollection()/BeanCollection functionality.
*
* @file RedBeanPHP/Cursor/PDOCursor.php
* @author Gabor de Mooij and the RedBeanPHP Community
* @license BSD/GPLv2
*
* @copyright
* (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
* This source file is subject to the BSD/GPLv2 License that is bundled
* with this source code in the file license.txt.
*/
class PDOCursor implements Cursor
{
/**
* @var PDOStatement
*/
protected $res;
/**
* @var string
*/
protected $fetchStyle;
/**
* Constructor, creates a new instance of a PDO Database Cursor.
*
* @param PDOStatement $res the PDO statement
* @param string $fetchStyle fetch style constant to use
*
* @return void
*/
public function __construct( \PDOStatement $res, $fetchStyle )
{
$this->res = $res;
$this->fetchStyle = $fetchStyle;
}
/**
* @see Cursor::getNextItem
*/
public function getNextItem()
{
return $this->res->fetch();
}
/**
* @see Cursor::reset
*/
public function reset()
{
$this->close();
$this->res->execute();
}
/**
* @see Cursor::close
*/
public function close()
{
$this->res->closeCursor();
}
}