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: *
12: * @file RedBeanPHP/Cursor/PDOCursor.php
13: * @author Gabor de Mooij and the RedBeanPHP Community
14: * @license BSD/GPLv2
15: *
16: * @copyright
17: * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
18: * This source file is subject to the BSD/GPLv2 License that is bundled
19: * with this source code in the file license.txt.
20: */
21: class PDOCursor implements Cursor
22: {
23: /**
24: * @var PDOStatement
25: */
26: protected $res;
27:
28: /**
29: * @var string
30: */
31: protected $fetchStyle;
32:
33: /**
34: * Constructor, creates a new instance of a PDO Database Cursor.
35: *
36: * @param PDOStatement $res the PDO statement
37: * @param string $fetchStyle fetch style constant to use
38: *
39: * @return void
40: */
41: public function __construct( \PDOStatement $res, $fetchStyle )
42: {
43: $this->res = $res;
44: $this->fetchStyle = $fetchStyle;
45: }
46:
47: /**
48: * @see Cursor::getNextItem
49: */
50: public function getNextItem()
51: {
52: return $this->res->fetch();
53: }
54:
55: /**
56: * @see Cursor::close
57: */
58: public function close()
59: {
60: $this->res->closeCursor();
61: }
62: }
63: