Yaffs site version 1.1
[yaffs-website] / vendor / gabordemooij / redbean / RedBeanPHP / Cursor / PDOCursor.php
1 <?php
2
3 namespace RedBeanPHP\Cursor;
4
5 use RedBeanPHP\Cursor as Cursor;
6
7 /**
8  * PDO Database Cursor
9  * Implementation of PDO Database Cursor.
10  * Used by the BeanCollection to fetch one bean at a time.
11  * The PDO Cursor is used by Query Writers to support retrieval
12  * of large bean collections. For instance, this class is used to
13  * implement the findCollection()/BeanCollection functionality.
14  *
15  * @file    RedBeanPHP/Cursor/PDOCursor.php
16  * @author  Gabor de Mooij and the RedBeanPHP Community
17  * @license BSD/GPLv2
18  *
19  * @copyright
20  * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
21  * This source file is subject to the BSD/GPLv2 License that is bundled
22  * with this source code in the file license.txt.
23  */
24 class PDOCursor implements Cursor
25 {
26         /**
27          * @var PDOStatement
28          */
29         protected $res;
30
31         /**
32          * @var string
33          */
34         protected $fetchStyle;
35
36         /**
37          * Constructor, creates a new instance of a PDO Database Cursor.
38          *
39          * @param PDOStatement $res        the PDO statement
40          * @param string       $fetchStyle fetch style constant to use
41          *
42          * @return void
43          */
44         public function __construct( \PDOStatement $res, $fetchStyle )
45         {
46                 $this->res = $res;
47                 $this->fetchStyle = $fetchStyle;
48         }
49
50         /**
51          * @see Cursor::getNextItem
52          */
53         public function getNextItem()
54         {
55                 return $this->res->fetch();
56         }
57
58         /**
59          * @see Cursor::close
60          */
61         public function close()
62         {
63                 $this->res->closeCursor();
64         }
65 }