Esempio n. 1
0
 /**
  * This function creates a data reader for query the specified SQL statement.
  *
  * @access public
  * @param string $sql                           the SQL statement
  * @return DB_SQL_DataReader                    the SQL data reader
  * @throws Throwable_SQL_Exception              indicates that the query failed
  */
 public function reader($sql)
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to create SQL data reader. Reason: Unable to find connection.');
     }
     $reader = DB_SQL_DataReader::factory($this, $sql);
     $this->sql = $sql;
     return $reader;
 }
Esempio n. 2
0
 /**
  * This function processes an SQL statement that will return data.
  *
  * @access public
  * @override
  * @param string $sql                           the SQL statement
  * @param string $type                          the return type to be used
  * @return DB_ResultSet                         the result set
  * @throws Throwable_SQL_Exception              indicates that the query failed
  */
 public function query($sql, $type = 'array')
 {
     if (!$this->is_connected()) {
         throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: Unable to find connection.');
     }
     $result_set = $this->cache($sql, $type);
     if ($result_set !== NULL) {
         $this->insert_id = FALSE;
         $this->sql = $sql;
         return $result_set;
     }
     $reader = DB_SQL_DataReader::factory($this, $sql);
     $result_set = $this->cache($sql, $type, new DB_ResultSet($reader, $type));
     $this->insert_id = FALSE;
     $this->sql = $sql;
     return $result_set;
 }