ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPDOStatement.php
Go to the documentation of this file.
1 <?php
2 
3 require_once 'Services/Database/interfaces/interface.ilDBStatement.php';
4 
11 class ilPDOStatement implements ilDBStatement
12 {
13 
17  protected $pdo_statement;
18 
19 
23  public function __construct(PDOStatement $pdo_statement)
24  {
25  $this->pdo_statement = $pdo_statement;
26  }
27 
28 
34  public function fetchRow($fetch_mode = ilDBConstants::FETCHMODE_ASSOC)
35  {
36  if ($fetch_mode == ilDBConstants::FETCHMODE_ASSOC) {
37  return $this->pdo_statement->fetch(PDO::FETCH_ASSOC);
38  } elseif ($fetch_mode == ilDBConstants::FETCHMODE_OBJECT) {
39  return $this->pdo_statement->fetch(PDO::FETCH_OBJ);
40  } else {
41  throw new ilDatabaseException("No valid fetch mode given, choose ilDBConstants::FETCHMODE_ASSOC or ilDBConstants::FETCHMODE_OBJECT");
42  }
43  }
44 
45 
50  public function fetch($fetch_mode = ilDBConstants::FETCHMODE_ASSOC)
51  {
52  return $this->fetchRow($fetch_mode);
53  }
54 
55 
59  public function closeCursor()
60  {
61  $this->pdo_statement->closeCursor();
62  }
63 
64 
68  public function rowCount()
69  {
70  return $this->pdo_statement->rowCount();
71  }
72 
73 
77  public function fetchObject()
78  {
80  }
81 
82 
86  public function fetchAssoc()
87  {
89  }
90 
91 
95  public function numRows()
96  {
97  return $this->pdo_statement->rowCount();
98  }
99 
100 
104  public function execute($a_data = null)
105  {
106  $this->pdo_statement->execute($a_data);
107 
108  return $this;
109  }
110 
114  public function errorCode()
115  {
116  return $this->pdo_statement->errorCode();
117  }
118 
122  public function errorInfo()
123  {
124  return $this->pdo_statement->errorInfo();
125  }
126 }
execute($a_data=null)
|
__construct(PDOStatement $pdo_statement)
Class ilPDOStatement is a Wrapper Class for PDOStatement.
fetch($fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
Class ilDatabaseException.
closeCursor()
Pdo allows for a manual closing of the cursor.
fetchRow($fetch_mode=ilDBConstants::FETCHMODE_ASSOC)
Interface ilDBStatement.