本文整理汇总了PHP中sqlite_fetch_array函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_fetch_array函数的具体用法?PHP sqlite_fetch_array怎么用?PHP sqlite_fetch_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_fetch_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
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: check_if_exists
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: query
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: read
/**
* 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: next
/**
* 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: fetch_array
function fetch_array($sql = "")
{
if ($sql == "") {
$sql = $this->query_id;
}
$this->record_row = @sqlite_fetch_array($sql, SQLITE_ASSOC);
return $this->record_row;
}
示例7: db_fetch_array
function db_fetch_array($res, $type = SQLITE_ASSOC)
{
$t = array();
while ($r = sqlite_fetch_array($res, $type)) {
$t[] = $r;
}
return $t;
}
示例8: read
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: fetchAll
/**
* Fetches all the results
* @return array
*/
function fetchAll()
{
$result = array();
while ($row = sqlite_fetch_array($this->query)) {
$result[] = $row;
}
return $result;
}
示例10: fetch
public function fetch()
{
$hRow = sqlite_fetch_array($this->oRes);
if ($this->sClass && $hRow) {
return Model::get_instance($this->sClass, $hRow);
}
return $hRow;
}
示例11: fetchArray
function fetchArray($sql)
{
$this->error = "";
if ($this->versi == 3) {
return $sql->fetchArray();
} else {
return sqlite_fetch_array($sql, SQLITE_ASSOC);
}
}
示例12: db_driver_result
/**
* 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: vdict_get
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: getOneRecord
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: next
function next()
{
$ret = FALSE;
if ($this->hasNext()) {
$this->current = sqlite_fetch_array($this->id, $this->mode);
$this->row++;
$ret = $this->current();
}
return $ret;
}