本文整理汇总了PHP中sqlite_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_num_fields函数的具体用法?PHP sqlite_num_fields怎么用?PHP sqlite_num_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite_num_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dl
<?php
if (!extension_loaded("sqlite")) {
dl("sqlite.so");
if (!extension_loaded("sqlite")) {
exit("Please enable SQLite support\n");
}
}
debug_zval_dump(sqlite_libversion());
debug_zval_dump(sqlite_libencoding());
$s = sqlite_open("weztest.sqlite", 0666, $err);
debug_zval_dump($err);
debug_zval_dump($s);
$r = sqlite_query("create table foo (a INTEGER PRIMARY KEY, b INTEGER )", $s);
debug_zval_dump(sqlite_last_error($s));
debug_zval_dump(sqlite_error_string(sqlite_last_error($s)));
$r = sqlite_query("select *, php('md5', sql) as o from sqlite_master", $s);
debug_zval_dump($r);
debug_zval_dump(sqlite_num_rows($r));
debug_zval_dump(sqlite_num_fields($r));
for ($j = 0; $j < sqlite_num_fields($r); $j++) {
echo "Field {$j} is " . sqlite_field_name($r, $j) . "\n";
}
while ($row = sqlite_fetch_array($r, SQLITE_ASSOC)) {
print_r($row);
}
sqlite_close($s);
示例2: getNFields
public function getNFields()
{
if ($this->_nfields === null) {
$this->_nfields = sqlite_num_fields($this->r);
}
return $this->_nfields;
}
示例3: columnCount
public function columnCount()
{
if ($this->_result) {
return sqlite_num_fields($this->_result);
}
return 0;
}
示例4: columnCount
/**
* Public method:
* Checks if query was valid and returns how may fields returns
* this->columnCount( void ):Void
*/
function columnCount()
{
$result = 0;
if (!is_null($this->__result)) {
$result = sqlite_num_fields($this->__result);
}
return $result;
}
示例5: getFields
/**
* Internal method to get a list of field names returned
*
* @return Integer
*/
public function getFields()
{
$fields = sqlite_num_fields($this->result);
$result = array();
for ($i = 0; $i < $fields; $i++) {
$result[$i] = sqlite_field_name($this->result, $i);
}
return $result;
}
示例6: __construct
/**
* Constructor
*
* @param resource handle
*/
public function __construct($result)
{
$fields = array();
if (is_resource($result)) {
for ($i = 0, $num = sqlite_num_fields($result); $i < $num; $i++) {
$fields[sqlite_field_name($result, $i)] = FALSE;
// Types are unknown
}
}
parent::__construct($result, $fields);
}
示例7: sqliteAdapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* @param resource $d The datasource resource
*/
function sqliteAdapter($d)
{
parent::RecordSetAdapter($d);
// grab all of the rows
$fieldcount = sqlite_num_fields($d);
// loop over all of the fields
for ($i = 0; $i < $fieldcount; $i++) {
// decode each field name ready for encoding when it goes through serialization
// and save each field name into the array
$this->columns[] = sqlite_field_name($d, $i);
}
if (sqlite_num_rows($d) > 0) {
$this->rows = sqlite_fetch_all($d, SQLITE_NUM);
}
}
示例8: sqliteAdapter
/**
* Constructor method for the adapter. This constructor implements the setting of the
* 3 required properties for the object.
*
* @param resource $d The datasource resource
*/
function sqliteAdapter($d)
{
parent::RecordSetAdapter($d);
// grab all of the rows
$fieldcount = sqlite_num_fields($d);
$ob = "";
$fc = pack('N', $fieldcount);
if (sqlite_num_rows($d) > 0) {
sqlite_seek($d, 0);
while ($line = sqlite_fetch_array($d, SQLITE_NUM)) {
//Write array flag + length
$ob .= "\n" . $fc;
$to = count($line);
for ($i = 0; $i < $to; $i++) {
//Type everything as a string since this is sqlite
$value = $line[$i];
$os = $this->_directCharsetHandler->transliterate($value);
//string flag, string length, and string
$len = strlen($os);
if ($len < 65536) {
$ob .= "" . pack('n', $len) . $os;
} else {
$ob .= "\f" . pack('N', $len) . $os;
}
}
}
}
// grab the number of fields
// loop over all of the fields
for ($i = 0; $i < $fieldcount; $i++) {
// decode each field name ready for encoding when it goes through serialization
// and save each field name into the array
$this->columnNames[$i] = $this->_directCharsetHandler->transliterate(sqlite_field_name($d, $i));
}
$this->numRows = sqlite_num_rows($d);
$this->serializedData = $ob;
}
示例9: getFieldInfo
function getFieldInfo($stack = 0)
{
$fields = array();
$i = 0;
if (($table = Session::get('select', 'table')) != '') {
// query from a table, so we can find keys related information using pragma
$this->result['_tinfo'] = @sqlite_query('PRAGMA table_info(' . $this->quote($table) . ')', $this->conn);
while ($row = $this->fetchRow('_tinfo')) {
$f = new StdClass();
$f->name = $row['name'];
$f->table = $table;
$f->not_null = $row['notnull'];
$f->blob = $row['type'] == 'BLOB' ? 1 : 0;
$f->pkey = $row['pk'];
$f->ukey = 0;
$f->mkey = 0;
$f->zerofill = 0;
$f->unsigned = 0;
$f->autoinc = 0;
$f->numeric = $row['type'] == 'INTEGER' ? 1 : 0;
$f->type = $row['type'] == 'INTEGER' ? 'numeric' : ($row['type'] == 'BLOB' ? 'binary' : 'text');
$fields[] = $f;
$i++;
}
} else {
while ($i < sqlite_num_fields($this->result[$stack])) {
$f = new StdClass();
$f->name = sqlite_field_name($this->result[$stack], $i);
$f->table = '';
$f->not_null = 0;
$f->blob = 0;
$f->pkey = 0;
$f->ukey = 0;
$f->mkey = 0;
$f->zerofill = 0;
$f->unsigned = 0;
$f->autoinc = 0;
$f->numeric = 0;
$f->type = 'string';
$fields[] = $f;
$i++;
}
}
return $fields;
}
示例10: sql_num_fields
function sql_num_fields($sqltype, $result)
{
if ($sqltype == 'mysql') {
if (class_exists('mysqli_result')) {
return $result->field_count;
} elseif (function_exists('mysql_num_fields')) {
return mysql_num_fields($result);
}
} elseif ($sqltype == 'mssql') {
if (function_exists('sqlsrv_num_fields')) {
return sqlsrv_num_fields($result);
} elseif (function_exists('mssql_num_fields')) {
return mssql_num_fields($result);
}
} elseif ($sqltype == 'pgsql') {
return pg_num_fields($result);
} elseif ($sqltype == 'oracle') {
return oci_num_fields($result);
} elseif ($sqltype == 'sqlite3') {
return $result->numColumns();
} elseif ($sqltype == 'sqlite') {
return sqlite_num_fields($result);
} elseif ($sqltype == 'odbc') {
return odbc_num_fields($result);
} elseif ($sqltype == 'pdo') {
return $result->columnCount();
}
}
示例11: columnCount
public function columnCount()
{
return $this->_result ? sqlite_num_fields($this->_result) : 0;
}
示例12: getColumnsMeta
/**
* Returns metadata for all columns in a result set.
*
* @return array
*/
public function getColumnsMeta()
{
$count = sqlite_num_fields($this->resultSet);
$meta = array();
for ($i = 0; $i < $count; $i++) {
// items 'name' and 'table' are required
$meta[] = array('name' => sqlite_field_name($this->resultSet, $i), 'table' => NULL);
}
return $meta;
}
示例13: getResultColumns
/**
* Returns metadata for all columns in a result set.
* @return array
*/
public function getResultColumns()
{
$count = sqlite_num_fields($this->resultSet);
$columns = array();
for ($i = 0; $i < $count; $i++) {
$name = str_replace(array('[', ']'), '', sqlite_field_name($this->resultSet, $i));
$pair = explode('.', $name);
$columns[] = array('name' => isset($pair[1]) ? $pair[1] : $pair[0], 'table' => isset($pair[1]) ? $pair[0] : NULL, 'fullname' => $name, 'nativetype' => NULL);
}
return $columns;
}
示例14: _initrs
function _initrs()
{
$this->_numOfRows = @sqlite_num_rows($this->_queryID);
$this->_numOfFields = @sqlite_num_fields($this->_queryID);
}
示例15: num_fields
function num_fields($resId = null)
{
if ($resId == null) {
$resId = $this->resId;
}
if (DEBUG) {
$out = sqlite_num_fields($resId);
} else {
$out = @sqlite_num_fields($resId);
}
return $out;
}