コード例 #1
0
ファイル: data.php プロジェクト: mudassartufail/dhtmlx
function get($db)
{
    // takes all records from database
    $result = sqlite_query($db, 'SELECT * FROM users');
    $users = array();
    while ($user = sqlite_fetch_array($result)) {
        $users[] = $user;
    }
    // generate json
    $json = array();
    for ($i = 0; $i < count($users); $i++) {
        $rec = "{";
        $rec .= 'id: "' . $users[$i]['id'] . '",';
        $rec .= 'name: "' . $users[$i]['name'] . '",';
        $rec .= 'age: "' . $users[$i]['age'] . '",';
        $rec .= 'group: "' . $users[$i]['group_name'] . '",';
        $rec .= 'city: "' . $users[$i]['city'] . '",';
        $rec .= 'phone: "' . $users[$i]['phone'] . '",';
        $rec .= 'sex: "' . $users[$i]['sex'] . '",';
        $rec .= 'driver_license: "' . $users[$i]['driver_license'] . '"';
        $rec .= "}";
        $json[] = $rec;
    }
    $json = '[' . implode(',', $json) . ']';
    return $json;
}
コード例 #2
0
function check_if_exists($cc)
{
    $result = safe_query("SELECT id FROM country_data WHERE cc_code_2='{$cc}'");
    $data = sqlite_fetch_array($result, SQLITE_NUM);
    // return the id or NULL if no data is avaliable
    return $data ? $data[0] : NULL;
}
コード例 #3
0
function query($db, $sql)
{
    $arr = array();
    if (IS_SQLITE3) {
        $rs = $db->query($sql);
        $len = $rs->numColumns();
        while ($row = $rs->fetchArray()) {
            $tmpArr = array();
            for ($i = 0; $i < $len; $i++) {
                $tmpArr[$i] = iconv("gb2312", "UTF-8", $row[$i]);
            }
            array_push($arr, $tmpArr);
        }
    } else {
        $rs = sqlite_query($db, $sql, SQLITE_NUM);
        //echo "<font color='red'>".$error."</font>";
        while ($row = sqlite_fetch_array($rs)) {
            $tmp = array();
            for ($i = 0; $i < count($row); $i++) {
                $tmp[$i] = iconv("gb2312", "UTF-8", $row[$i]);
            }
            array_push($arr, $tmp);
        }
    }
    return $arr;
}
コード例 #4
0
ファイル: Standard.php プロジェクト: ruslankus/invoice-crm
 /**
  * This function advances the reader to the next record.
  *
  * @access public
  * @override
  * @return boolean                          whether another record was fetched
  */
 public function read()
 {
     if ($this->command !== NULL) {
         $this->record = @sqlite_fetch_array($this->command, SQLITE_ASSOC);
     }
     return $this->record !== FALSE;
 }
コード例 #5
0
 /**
  * Iterator function. Returns a rowset if called without parameter,
  * the fields contents if a field is specified or FALSE to indicate
  * no more rows are available.
  *
  * @param   string field default NULL
  * @return  var
  */
 public function next($field = NULL)
 {
     if (!is_resource($this->handle) || FALSE === ($row = sqlite_fetch_array($this->handle, SQLITE_ASSOC))) {
         return FALSE;
     }
     foreach (array_keys($row) as $key) {
         if (NULL === $row[$key] || !isset($this->fields[$key])) {
             continue;
         }
         switch ($row[$key][0]) {
             case "":
                 $row[$key] = Date::fromString(substr($row[$key], 1));
                 break;
             case "":
                 $row[$key] = intval(substr($row[$key], 1));
                 break;
             case "":
                 $row[$key] = floatval(substr($row[$key], 1));
                 break;
         }
     }
     if ($field) {
         return $row[$field];
     } else {
         return $row;
     }
 }
コード例 #6
0
ファイル: db_sqlite.php プロジェクト: rust1989/edit
 function fetch_array($sql = "")
 {
     if ($sql == "") {
         $sql = $this->query_id;
     }
     $this->record_row = @sqlite_fetch_array($sql, SQLITE_ASSOC);
     return $this->record_row;
 }
コード例 #7
0
ファイル: sqlite.inc.php プロジェクト: vulnerabilityCode/ctf
function db_fetch_array($res, $type = SQLITE_ASSOC)
{
    $t = array();
    while ($r = sqlite_fetch_array($res, $type)) {
        $t[] = $r;
    }
    return $t;
}
コード例 #8
0
ファイル: session.php プロジェクト: laiello/php-garden
 public static function read($id)
 {
     $t = time();
     $sql = "SELECT data FROM sess WHERE expire > {$t} AND id = '" . sqlite_escape_string($id) . "'";
     $r = sqlite_query($sql, SESSION_DB_LINK);
     $d = sqlite_fetch_array($r);
     return '' . is_array($d) ? array_shift($d) : false;
 }
コード例 #9
0
 /**
  * Fetches all the results
  * @return array
  */
 function fetchAll()
 {
     $result = array();
     while ($row = sqlite_fetch_array($this->query)) {
         $result[] = $row;
     }
     return $result;
 }
コード例 #10
0
ファイル: SQLiteDBResult.php プロジェクト: poitch/dokin
 public function fetch()
 {
     $hRow = sqlite_fetch_array($this->oRes);
     if ($this->sClass && $hRow) {
         return Model::get_instance($this->sClass, $hRow);
     }
     return $hRow;
 }
コード例 #11
0
ファイル: sqlite.php プロジェクト: HuiZone/Waruga
 function fetchArray($sql)
 {
     $this->error = "";
     if ($this->versi == 3) {
         return $sql->fetchArray();
     } else {
         return sqlite_fetch_array($sql, SQLITE_ASSOC);
     }
 }
コード例 #12
0
ファイル: db_sqlite.php プロジェクト: refirio/levis
/**
 * Get the result from the database.
 *
 * @param resource $resource
 *
 * @return array
 */
function db_driver_result($resource)
{
    global $_db;
    $results = array();
    while ($data = sqlite_fetch_array($resource, SQLITE_ASSOC)) {
        $results[] = $data;
    }
    return $results;
}
コード例 #13
0
ファイル: vdict.php プロジェクト: n2i/xvnkb
function vdict_get($db, $word)
{
    if ($db instanceof PDO) {
        $res = $db->query('SELECT * FROM dict WHERE word = ' . $db->quote($word));
        return $res->fetch();
    }
    $res = sqlite_query($db, "SELECT * FROM dict WHERE word = '{$word}'");
    return sqlite_fetch_array($res);
}
コード例 #14
0
 function getOneRecord()
 {
     $record = new lmbSqliteRecord();
     $queryId = $this->connection->execute($this->getSQL());
     $values = sqlite_fetch_array($queryId, SQLITE_ASSOC);
     if (is_array($values)) {
         $record->import($values);
         return $record;
     }
 }
コード例 #15
0
ファイル: sqlite.php プロジェクト: BackupTheBerlios/k4bb-svn
 function next()
 {
     $ret = FALSE;
     if ($this->hasNext()) {
         $this->current = sqlite_fetch_array($this->id, $this->mode);
         $this->row++;
         $ret = $this->current();
     }
     return $ret;
 }
コード例 #16
0
 public function FetchArray($result)
 {
     if ($this->connection === false) {
         throw new DatabaseEx('Not connected to a database server!');
     } elseif (!is_resource($result)) {
         throw new DatabaseEx('Invalid Resource For fetchArray()');
     }
     $data = @sqlite_fetch_array($result);
     return $data;
 }
コード例 #17
0
ファイル: dic.php プロジェクト: kosenconf/kcweb
 /**
  * Create output
  */
 function render($format, &$R, $data)
 {
     if ($format != 'xhtml') {
         return false;
     }
     if (is_null($data)) {
         return false;
     }
     $R->info['cache'] = false;
     $sqlite = $this->dthlp->_getDB();
     if (!$sqlite) {
         return false;
     }
     $this->updateSQLwithQuery($data);
     // handles request params
     // run query
     $clist = array_keys($data['cols']);
     $res = $sqlite->query($data['sql']);
     $cnt = 0;
     $rows = array();
     while ($row = sqlite_fetch_array($res, SQLITE_NUM)) {
         $rows[] = $row;
         $cnt++;
         if ($data['limit'] && $cnt == $data['limit']) {
             break;
         }
         // keep an eye on the limit
     }
     if ($cnt === 0) {
         $this->nullList($data, $clist, $R);
         return true;
     }
     $R->doc .= $this->preList($clist, $data);
     foreach ($rows as $row) {
         // build data rows
         $R->doc .= $this->before_item;
         foreach ($row as $num => $cval) {
             if ($clist[$num] !== "%pageid%") {
                 // print title
                 $R->doc .= "<br>";
                 $R->doc .= $this->before_title;
                 $R->doc .= $clist[$num];
                 $R->doc .= ": ";
                 $R->doc .= $this->after_title;
             }
             // print val
             $R->doc .= $this->before_val;
             $R->doc .= $this->dthlp->_formatData($data['cols'][$clist[$num]], $cval, $R);
             $R->doc .= $this->after_val;
         }
         $R->doc .= $this->after_item;
     }
     $R->doc .= $this->postList($data, sqlite_num_rows($res));
     return true;
 }
コード例 #18
0
 function getAllContents($file)
 {
     $db = sqlite_open($file);
     $rs = sqlite_query('SELECT * FROM trans_unit', $db);
     $result = '';
     while ($row = sqlite_fetch_array($rs, SQLITE_NUM)) {
         $result .= implode(', ', $row) . "\n";
     }
     sqlite_close($db);
     return $result;
 }
コード例 #19
0
ファイル: helpers.php プロジェクト: Alamantus/PHP-App-Base
function fetch_assoc($query_results)
{
    if (DATABASE_TYPE == "mysql") {
        $results = mysqli_fetch_assoc($query_results);
    } elseif (DATABASE_TYPE == "sqlite") {
        $results = sqlite_fetch_array($query_results, SQLITE_ASSOC);
    } elseif (DATABASE_TYPE == "pgsql") {
        $results = pg_fetch_assoc($query_results);
    }
    return $results;
}
コード例 #20
0
 /**
  * 执行一个数据库查询语句,并返回第一行结果
  * @param string $sql
  * @return array
  * @throws Exception
  */
 public function queryAndFetch($sql)
 {
     if (!$this->db) {
         throw new Exception("sqlite db not connected error");
     }
     if ($this->sqlite_version == 2) {
         return sqlite_fetch_array(sqlite_unbuffered_query($this->db, $sql));
     } else {
         return $this->db->query($sql)->fetch();
     }
 }
コード例 #21
0
ファイル: sql_fetch_row.php プロジェクト: eodivision/eoCMS
function sql_fetch_row($data)
{
    if (defined('DB_TYPE')) {
        if (DB_TYPE == 'mysql') {
            $sql = mysql_fetch_row($data);
        } elseif (DB_TYPE == 'sqlite') {
            $sql = sqlite_fetch_array($data, SQLITE_NUM);
        }
        return $sql;
    }
}
コード例 #22
0
 protected function db_fetch_wrapper($resource)
 {
     if (in_array($resource, array(null, false, true), true)) {
         $result = false;
     } else {
         if (($result = sqlite_fetch_array($resource, SQLITE_ASSOC)) === null) {
             $result = false;
         }
     }
     return $result;
 }
コード例 #23
0
ファイル: pfhostsedit.php プロジェクト: allard-archive/pfw
function set_pfhost_nonwritable($name)
{
    global $database;
    $db = sqlite_popen($database);
    $results = sqlite_query("select * from pfhosts where name='" . sqlite_escape_string($name) . "'", $db);
    $pfhost_check = sqlite_fetch_array($results, SQLITE_ASSOC);
    if ($pfhost_check['can_connect'] == "true") {
        $results = sqlite_query("update pfhosts set can_connect='false' where name='" . sqlite_escape_string($name) . "'", $db);
    }
    sqlite_close($db);
}
コード例 #24
0
/**
 * Implementation of hook_dirlist.
 */
function ft_fileinfo_dirlist()
{
    global $ft;
    $sql = 'SELECT name, description FROM fileinfo WHERE dir = ' . sqlite_escape_string(ft_get_dir());
    $result = sqlite_query($ft['db']['link'], $sql);
    if ($result) {
        while ($entry = sqlite_fetch_array($query, SQLITE_ASSOC)) {
            $ft['fileinfo']['descriptions'][$entry['file']] = $entry['description'];
        }
    }
}
コード例 #25
0
 /**
  * @throws SQLException
  * @return void
  */
 protected function initTables()
 {
     include_once 'creole/drivers/sqlite/metadata/SQLiteTableInfo.php';
     $sql = "SELECT name FROM sqlite_master WHERE type='table' UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name;";
     $result = sqlite_query($this->dblink, $sql);
     if (!$result) {
         throw new SQLException("Could not list tables", sqlite_last_error($this->dblink));
     }
     while ($row = sqlite_fetch_array($result)) {
         $this->tables[strtoupper($row[0])] = new SQLiteTableInfo($this, $row[0]);
     }
 }
コード例 #26
0
ファイル: Result.php プロジェクト: chrismcmacken/phptools
 /**
  * Return an associative array of converted data
  *
  * @return array Associative array of row's data
  */
 protected function fetchRowAssocDb()
 {
     $row = sqlite_fetch_array($this->resource, SQLITE_ASSOC);
     $out = array();
     foreach ($row as $k => $v) {
         if (substr($k, 0, 1) == '"' && substr($k, -1) == '"') {
             $k = substr($k, 1, -1);
         }
         $out[$k] = $v;
     }
     return $out;
 }
コード例 #27
0
ファイル: sqlite.class.php プロジェクト: Terrorboy/SQLite
 function fetch($type = SQLITE_BOTH)
 {
     if ($type == 1) {
         $type = SQLITE_ASSOC;
     } elseif ($type == 2) {
         $type = SQLITE_NUM;
     } elseif ($type == 3 || $type != SQLITE_BOTH) {
         $type = SQLITE_BOTH;
     }
     //
     return sqlite_fetch_array($this->query, $type);
 }
コード例 #28
0
ファイル: sqlite.php プロジェクト: piotras/midgardmvc_core
 public function get($module, $identifier)
 {
     $module = sqlite_escape_string($module);
     $identifier = sqlite_escape_string($identifier);
     $results = sqlite_query($this->_db, "SELECT value FROM {$this->_table} WHERE module='{$module}' AND identifier='{$identifier}'");
     $results = sqlite_fetch_array($results);
     if (count($results) == 0) {
         return false;
         // no hit
     }
     return unserialize($results[0]);
 }
コード例 #29
0
ファイル: sql_fetch_array.php プロジェクト: eodivision/eoCMS
function sql_fetch_array($data)
{
    global $con;
    if (defined('DB_TYPE')) {
        if (DB_TYPE == 'mysql') {
            $sql = mysql_fetch_array($data);
        } elseif (DB_TYPE == 'sqlite') {
            $sql = sqlite_fetch_array($data);
        }
    }
    return $sql;
}
コード例 #30
0
 public function executeSQL($a_query)
 {
     if (!$this->db) {
         return NULL;
     }
     $result = sqlite_query($this->db, $a_query);
     $res = array();
     while ($temp = sqlite_fetch_array($result)) {
         $res[] = $temp;
     }
     return $res;
 }