public function fetch_object($ch, $cn = NULL)
 {
     if (isset($cn) && class_exists($cn)) {
         return sqlite_fetch_object($ch, $cn);
     }
     return sqlite_fetch_object($ch);
 }
Exemple #2
0
function db_single($sql)
{
    global $db;
    $args = func_get_args();
    $sql = db_compile_query($sql, $args);
    $res = @sqlite_query($db, $sql);
    if ($res) {
        return @sqlite_fetch_object($res);
    }
    return false;
}
function sql_fetch_object($data)
{
    if (defined('DB_TYPE')) {
        if (DB_TYPE == 'mysql') {
            $sql = mysql_fetch_object($data);
        } elseif (DB_TYPE == 'sqlite') {
            $sql = sqlite_fetch_object($data);
        }
        return $sql;
    }
}
 function _fetch_object()
 {
     if (function_exists('sqlite_fetch_object')) {
         return sqlite_fetch_object($this->result_id);
     } else {
         $arr = sqlite_fetch_array($this->result_id, SQLITE_ASSOC);
         if (is_array($arr)) {
             $obj = (object) $arr;
             return $obj;
         } else {
             return NULL;
         }
     }
 }
 protected function _fetch()
 {
     $ret = sqlite_fetch_object($this->_idResult);
     return $ret;
     /*if($this->_fetchMode == jDbConnection::FETCH_CLASS){
           if ($this->_fetchModeCtoArgs)
               $ret =  sqlite_fetch_object ($this->_idResult, $this->_fetchModeParam, $this->_fetchModeCtoArgs);
           else
               $ret =  sqlite_fetch_object ($this->_idResult, $this->_fetchModeParam);
       }else{
           $ret =  sqlite_fetch_object ($this->_idResult);
       }
       return $ret;*/
 }
Exemple #6
0
function collectPreviousState()
{
    if (($sql = sqlite_open(CM_HOME . '/etc/check.db', 0666, $sqliteerror)) === FALSE) {
        error_log("CheckP2P: impossible d'ouvrir la base de donnees");
        //@unlink ( SQLITE_DB );
    }
    if (($result = sqlite_query($sql, "SELECT * FROM state;")) === FALSE) {
        error_log("CheckP2P: impossible d'executer la requete SQLite");
        return FALSE;
    }
    while (($point = sqlite_fetch_object($result)) !== FALSE) {
        $points[$point->point] = $point;
    }
    sqlite_close($sql);
    return $points;
}
 public function current()
 {
     if ($this->_current_row !== $this->_internal_row and !$this->seek($this->_current_row)) {
         return NULL;
     }
     // Increment internal row for optimization assuming rows are fetched in order
     $this->_internal_row++;
     if ($this->_as_object === TRUE) {
         // Return an stdClass
         return sqlite_fetch_object($this->_result);
     } elseif (is_string($this->_as_object)) {
         // Return an object of given class name
         return sqlite_fetch_object($this->_result, $this->_as_object, $this->_object_params);
     } else {
         // Return an array of the row
         return sqlite_fetch_array($this->_result);
     }
 }
 public function fetch($query, $type = SEBODB_ASSOC)
 {
     $r = false;
     if (!is_resource($query)) {
         trigger_error('SeboDB:SQLite argument provided is not a valid result resource', E_USER_WARNING);
     }
     if ($type === SEBODB_ARRAY) {
         $r = sqlite_fetch_array($query, SQLITE_NUM);
     } elseif ($type === SEBODB_ASSOC) {
         $r = sqlite_fetch_array($query, SQLITE_ASSOC);
     } elseif ($type === SEBODB_OBJECT) {
         $r = sqlite_fetch_object($query);
     } elseif ($type === SEBODB_FIELD) {
         // FINISH ME FINISH ME FINISH ME
         $r = sqlite_fetch_array($query);
     } elseif ($type === SEBODB_LENGTHS) {
         $r = mysql_fetch_lengths($query);
     } else {
         trigger_error('SeboDB:SQLite invalid type argument', E_USER_WARNING);
     }
     return $r;
 }
Exemple #9
0
 /**
  * Database_SQLite::query
  *
  * Executes a SQL query and returns an array of row result objects.
  */
 function query($sql)
 {
     if (!empty($this->pdo)) {
         return $this->pdo->query($sql);
     }
     $result = sqlite_query($sql, $this->conn);
     $rows = array();
     if (is_resource($result)) {
         while ($row = sqlite_fetch_object($result)) {
             foreach (get_object_vars($row) as $key => $value) {
                 if (preg_match('/[\\w_]+\\.(.+)/', $key, $matches)) {
                     list(, $column_name) = $matches;
                     $row->{$column_name} = $value;
                 }
             }
             $rows[] = $row;
         }
     }
     $error = sqlite_last_error($this->conn);
     if (!empty($error)) {
         trigger_error("{$error} ({$sql})");
     }
     return $rows;
 }
Exemple #10
0
 /**
  * Renvoie sous forme d'objet la ligne suivante dans le jeu de résultat
  * 
  * @access public
  * @return object
  */
 function fetchObject()
 {
     return sqlite_fetch_object($this->result);
 }
 /**
  * Fetch a result row as an object
  *
  * @param none
  * @return Array $this->sqlStoreValues
  */
 public function fetchObject()
 {
     $sqlStoreValues = array();
     while ($this->sqlRows = sqlite_fetch_object($this->sqlExec)) {
         $sqlStoreValues[] = $this->sqlRows;
     }
     $this->freeResult();
     return $sqlStoreValues;
 }
 /**
  * Public method:
  *	Returns an array with all rows of executed query.
  *       	this->fetchAll( $mode:Integer ):Array
  * @Param	Integer		PDO_FETCH_* constant to know how to read all rows, default PDO_FETCH_BOTH
  * 				NOTE: this doesn't work as fetch method, then it will use always PDO_FETCH_BOTH
  *                                    if this param is omitted
  * @Return	Array		An array with all fetched rows
  */
 function fetchAll($mode = PDO_FETCH_BOTH)
 {
     $result = array();
     if (!is_null($this->__result)) {
         switch ($mode) {
             case PDO_FETCH_NUM:
                 while ($r = sqlite_fetch_array($this->__result, SQLITE_NUM)) {
                     array_push($result, $r);
                 }
                 break;
             case PDO_FETCH_ASSOC:
                 while ($r = sqlite_fetch_array($this->__result, SQLITE_ASSOC)) {
                     array_push($result, $r);
                 }
                 break;
             case PDO_FETCH_OBJ:
                 while ($r = sqlite_fetch_object($this->__result)) {
                     array_push($result, $r);
                 }
                 break;
             case PDO_FETCH_BOTH:
             default:
                 while ($r = sqlite_fetch_array($this->__result, SQLITE_BOTH)) {
                     array_push($result, $r);
                 }
                 break;
         }
     }
     $this->__result = null;
     return $result;
 }
Exemple #13
0
 /**
  * Fetch a result row as an object
  *
  * @param   mixed $result
  * @return object
  */
 public function fetch_object($result)
 {
     return sqlite_fetch_object($result);
 }
 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @param	string	$class_name
  * @return	object
  */
 protected function _fetch_object($class_name = 'stdClass')
 {
     return sqlite_fetch_object($this->result_id, $class_name);
 }
Exemple #15
0
 function fetch_object($query, $case = 0)
 {
     $this->error = "";
     //Set the errors to none
     if ($this->debug) {
         $this->debugmsg("Fetching object on " . $this->dbtype . " database....", "blue");
         $this->debugmsg($query, "purple");
     }
     switch ($this->dbtype) {
         /* Firebird Functionality */
         case "firebird":
             $query = ibase_fetch_object($query);
             break;
             /* SQLite Functionality */
         /* SQLite Functionality */
         case "sqlite":
             $query = sqlite_fetch_object($query);
             break;
             /*DBASE - this uses the record counter - currentrecord */
         /*DBASE - this uses the record counter - currentrecord */
         case "dbase":
             if ($this->currentrecord <= $this->num_rows($none)) {
                 $temp = dbase_get_record_with_names($this->dbh, $this->currentrecord);
                 $this->currentrecord++;
                 foreach ($temp as $name => $value) {
                     $name = $name;
                     $value = str_replace("'", "''", $value);
                     $query->{$name} = trim($value);
                 }
             } else {
                 $query = false;
             }
             break;
             /* MYSQL Functionality */
         /* MYSQL Functionality */
         case "mysql":
             //echo $query;
             $query = mysql_fetch_object($query);
             break;
             /* Oracle Functionality */
         /* Oracle Functionality */
         case "oracle":
             $query = oci_fetch_object($query);
             break;
             /* MSSQL Functionality */
         /* MSSQL Functionality */
         case "mssql":
             $query = mssql_fetch_object($query);
             break;
             /* PGSQL Functionality */
         /* PGSQL Functionality */
         case "pgsql":
             $query = pg_fetch_object($query);
             break;
     }
     //because of field name differences i choose to make all results uppercase as with firebird conventions as default
     //print_r ($query);
     if ($case == 0) {
         if (is_object($query)) {
             foreach ($query as $name => $value) {
                 //Clean up the underscores and other characters
                 $testname = str_replace("_", "", $name);
                 if (ctype_lower($testname)) {
                     unset($query->{$name});
                 }
                 $name = strtoupper($name);
                 $query->{$name} = $value;
             }
         }
     } else {
         if (is_object($query)) {
             foreach ($query as $name => $value) {
                 //Clean up the underscores and other characters
                 $testname = str_replace("_", "", $name);
                 if (ctype_upper($testname)) {
                     unset($query->{$name});
                 }
                 $name = strtolower($name);
                 $query->{$name} = $value;
             }
         }
     }
     if ($this->debug) {
         $this->debugmsg("Fetched object for " . $this->dbtype . " database....", "green");
         $this->debugmsg($this->pre_r($query), "purple");
     }
     return $query;
 }
 protected function _fetch()
 {
     $ret = sqlite_fetch_object($this->_idResult);
     return $ret;
 }
Exemple #17
0
<pre>
<?php 
$db = sqlite_open(dirname(__FILE__) . "/db.sqlite");
$res = sqlite_query("SELECT * FROM auth_tbl", $db);
/* fetch each row as an object */
while ($obj = sqlite_fetch_object($res)) {
    var_dump($obj);
}
sqlite_close($db);
?>
</pre>
Exemple #18
0
function db_fetch_object($result)
{
    if ($result) {
        if (mysql) {
            return mysql_fetch_object($result);
        } else {
            if (sqlite2) {
                return sqlite_fetch_object($result);
            } else {
                if (sqlite3) {
                    $rec = $result->fetchArray(SQLITE3_ASSOC);
                    if ($rec === FALSE) {
                        return FALSE;
                    }
                    $rec = (object) $rec;
                    return $rec;
                } else {
                    if (pdo_sqlite) {
                        return $result->fetchObject();
                    } else {
                        die("db_fetch_object: unknown database");
                    }
                }
            }
        }
    }
}
 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @access	private
  * @return	object
  */
 function _fetch_object()
 {
     if (function_exists('sqlite_fetch_object')) {
         return sqlite_fetch_object($this->result_id);
     } else {
         return $this->_fetch_assoc();
     }
 }
Exemple #20
0
 public function fetch_object($resource = '')
 {
     return sqlite_fetch_object(self::resource($resource));
 }
Exemple #21
0
 public function fetchOneAsObject($count = false)
 {
     if ($item = sqlite_fetch_object($this->resource)) {
         return $item;
     } else {
         return new stdClass();
     }
     $this->enhanceResult($result);
     return $result;
 }
Exemple #22
0
 public function fetch_one()
 {
     return sqlite_fetch_object($this->resource);
 }
Exemple #23
0
<?php

/* eoCMS is a content management system written in php
    Copyright (C) 2007 - 2009  James Mortemore, Ryan Matthews
    http://www.eocms.com    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 3 of the License

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
$sql = sqlite_fetch_object($data);
 /**
  * SQLiteAdapter::fetchAll()
  * 
  * @param bool $query
  * @param string $type
  * @return
  */
 public function fetchAll($query = false, $type = 'assoc')
 {
     if ($query != false) {
         $this->query($query);
     }
     if ($this->result !== false) {
         if ($type == 'assoc') {
             return sqlite_fetch_all($this->result, SQLITE_ASSOC);
         }
         if ($type == 'object') {
             $output = array();
             while ($row = sqlite_fetch_object($this->result)) {
                 $output[] = $row;
             }
         }
         return $output;
     }
     return false;
 }
 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @access	private
  * @return	object
  */
 function _fetch_object()
 {
     return sqlite_fetch_object($this->result_id);
 }
Exemple #26
0
 function fetch_all_objects($q = false, $classname = "", $primary_key = "")
 {
     if ($q === false) {
         $q = $this->lastresource;
     } elseif (is_string($q)) {
         $q = $this->query($q);
     }
     if (!$q) {
         return false;
     }
     $objects = array();
     while ($this->sqlite2 ? $classname && ($o = sqlite_fetch_object($q, $classname)) !== false || !$classname && ($o = sqlite_fetch_object($q)) !== false : ($o = $q->fetchArray(SQLITE3_ASSOC)) && ($classname && ($o = new $classname($o)) || !$classname)) {
         if ($primary_key) {
             $objects[$classname ? $o->{$primary_key} : $o[$primary_key]] = $o;
         } else {
             $objects[] = $o;
         }
     }
     return $objects;
 }
Exemple #27
0
 public function fetchObject($class_name = null, $ctor_args = null)
 {
     if (is_null($class_name)) {
         return sqlite_fetch_object($this->_result);
     } else {
         if (is_array($ctor_args)) {
             return sqlite_fetch_object($this->_result, $class_name, $ctor_args);
         } else {
             return sqlite_fetch_object($this->_result, $class_name);
         }
     }
 }
 function fetchObject($class_name)
 {
     return sqlite_fetch_object($this->__result, $class_name);
 }
Exemple #29
0
 function FetchObject($result)
 {
     return sqlite_fetch_object($result);
 }
 function getNext($resultType = ANYDB_PREDEFINED_VALUE)
 {
     if ($resultType == ANYDB_PREDEFINED_VALUE) {
         $resultType = $this->prefResType;
     }
     $res = false;
     // get next result set
     if ($this->result != null) {
         switch ($resultType) {
             case ANYDB_RES_ASSOC:
                 $res = @sqlite_fetch_array($this->result, SQLITE_ASSOC);
                 break;
             case ANYDB_RES_NUM:
                 $res = @sqlite_fetch_array($this->result, SQLITE_NUM);
                 break;
             case ANYDB_RES_BOTH:
                 $res = @sqlite_fetch_array($this->result, SQLITE_BOTH);
                 break;
             case ANYDB_RES_OBJ:
                 if (function_exists('sqlite_fetch_object')) {
                     $res = @sqlite_fetch_object($this->result);
                 } else {
                     $this->_addError("Need PHP5 to fetch an object!", 'getNext(ANYDB_RES_OBJ)');
                 }
                 break;
             default:
                 $this->_addError("Wrong result type!", 'getNext()');
         }
     }
     return $res;
 }