本文整理汇总了PHP中ifx_query函数的典型用法代码示例。如果您正苦于以下问题:PHP ifx_query函数的具体用法?PHP ifx_query怎么用?PHP ifx_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ifx_query函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _query
function _query($sql, $inputarr = false)
{
global $ADODB_COUNTRECS;
// String parameters have to be converted using ifx_create_char
if ($inputarr) {
foreach ($inputarr as $v) {
if (gettype($v) == 'string') {
$tab[] = ifx_create_char($v);
} else {
$tab[] = $v;
}
}
}
// In case of select statement, we use a scroll cursor in order
// to be able to call "move", or "movefirst" statements
if (!$ADODB_COUNTRECS && preg_match("/^\\s*select/is", $sql)) {
if ($inputarr) {
$this->lastQuery = ifx_query($sql, $this->_connectionID, $this->cursorType, $tab);
} else {
$this->lastQuery = ifx_query($sql, $this->_connectionID, $this->cursorType);
}
} else {
if ($inputarr) {
$this->lastQuery = ifx_query($sql, $this->_connectionID, $tab);
} else {
$this->lastQuery = ifx_query($sql, $this->_connectionID);
}
}
// Following line have been commented because autocommit mode is
// not supported by informix SE 7.2
//if ($this->_autocommit) ifx_query('COMMIT',$this->_connectionID);
return $this->lastQuery;
}
示例2: insert
//.........这里部分代码省略.........
if (PEAR::isError($value)) {
$this->raiseError($value->toString(), DB_DATAOBJECT_ERROR_INVALIDARGS);
return false;
}
$rightq .= $value;
continue;
}
if (!($v & DB_DATAOBJECT_NOTNULL) && DB_DataObject::_is_null($this, $k)) {
$rightq .= " NULL ";
continue;
}
// DATE is empty... on a col. that can be null..
// note: this may be usefull for time as well..
if (!$this->{$k} && ($v & DB_DATAOBJECT_DATE || $v & DB_DATAOBJECT_TIME) && !($v & DB_DATAOBJECT_NOTNULL)) {
$rightq .= " NULL ";
continue;
}
if ($v & DB_DATAOBJECT_STR) {
$rightq .= $this->_quote((string) ($v & DB_DATAOBJECT_BOOL ? $this->{$k} === 'f' ? 0 : (int) (bool) $this->{$k} : $this->{$k})) . " ";
continue;
}
if (is_numeric($this->{$k})) {
$rightq .= " {$this->{$k}} ";
continue;
}
/* flag up string values - only at debug level... !!!??? */
if (is_object($this->{$k}) || is_array($this->{$k})) {
$this->debug('ODD DATA: ' . $k . ' ' . print_r($this->{$k}, true), 'ERROR');
}
// at present we only cast to integers
// - V2 may store additional data about float/int
$rightq .= ' ' . intval($this->{$k}) . ' ';
}
// not sure why we let empty insert here.. - I guess to generate a blank row..
if ($leftq || $useNative) {
$table = $quoteIdentifiers ? $DB->quoteIdentifier($this->__table) : $this->__table;
if ($dbtype == 'pgsql' && empty($leftq)) {
$r = $this->_query("INSERT INTO {$table} DEFAULT VALUES");
} else {
$r = $this->_query("INSERT INTO {$table} ({$leftq}) VALUES ({$rightq}) ");
}
if (PEAR::isError($r)) {
$this->raiseError($r);
return false;
}
if ($r < 1) {
return 0;
}
// now do we have an integer key!
if ($key && $useNative) {
switch ($dbtype) {
case 'mysql':
case 'mysqli':
$method = "{$dbtype}_insert_id";
$this->{$key} = $method($_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection);
break;
case 'mssql':
// note this is not really thread safe - you should wrapp it with
// transactions = eg.
// $db->query('BEGIN');
// $db->insert();
// $db->query('COMMIT');
$db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
$method = $db_driver == 'DB' ? 'getOne' : 'queryOne';
$mssql_key = $DB->{$method}("SELECT @@IDENTITY");
if (PEAR::isError($mssql_key)) {
$this->raiseError($mssql_key);
return false;
}
$this->{$key} = $mssql_key;
break;
case 'pgsql':
if (!$seq) {
$seq = $DB->getSequenceName(strtolower($this->__table));
}
$db_driver = empty($options['db_driver']) ? 'DB' : $options['db_driver'];
$method = $db_driver == 'DB' ? 'getOne' : 'queryOne';
$pgsql_key = $DB->{$method}("SELECT currval('" . $seq . "')");
if (PEAR::isError($pgsql_key)) {
$this->raiseError($pgsql_key);
return false;
}
$this->{$key} = $pgsql_key;
break;
case 'ifx':
$this->{$key} = array_shift(ifx_fetch_row(ifx_query("select DBINFO('sqlca.sqlerrd1') FROM systables where tabid=1", $_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection, IFX_SCROLL), "FIRST"));
break;
}
}
if (isset($_DB_DATAOBJECT['CACHE'][strtolower(get_class($this))])) {
$this->_clear_cache();
}
if ($key) {
return $this->{$key};
}
return true;
}
$this->raiseError("insert: No Data specifed for query", DB_DATAOBJECT_ERROR_NODATA);
return false;
}
示例3: query
/**
* Efectua operaciones SQL sobre la base de datos
*
* @param string $sqlQuery
* @return resource or false
*/
public function query($sql_query)
{
$this->debug($sql_query);
if ($this->logger) {
Logger::debug($sql_query);
}
if (!$this->id_connection) {
$this->connect();
if (!$this->id_connection) {
return false;
}
}
$this->last_query = $sql_query;
// Los resultados que devuelven filas usan cursores tipo SCROLL
if ($this->return_rows) {
$result_query = ifx_query($sql_query, $this->id_connection, IFX_HOLD);
} else {
$result_query = ifx_query($sql_query, $this->id_connection);
}
$this->set_return_rows(true);
if ($result_query === false) {
$this->last_result_query = false;
throw new KumbiaException($this->error(" al ejecutar <em>\"{$sql_query}\"</em>"));
} else {
$this->last_result_query = $result_query;
return $result_query;
}
}
示例4: tableInfo
/**
* Returns information about a table or a result set
*
* NOTE: only supports 'table' if <var>$result</var> is a table name.
*
* If analyzing a query result and the result has duplicate field names,
* an error will be raised saying
* <samp>can't distinguish duplicate field names</samp>.
*
* @param object|string $result DB_result object from a query or a
* string containing the name of a table.
* While this also accepts a query result
* resource identifier, this behavior is
* deprecated.
* @param int $mode a valid tableInfo mode
*
* @return array an associative array with the information requested.
* A DB_Error object on failure.
*
* @see DB_common::tableInfo()
* @since Method available since Release 1.6.0
*/
function tableInfo($result, $mode = null)
{
if (is_string($result)) {
/*
* Probably received a table name.
* Create a result resource identifier.
*/
$id = @ifx_query("SELECT * FROM {$result} WHERE 1=0", $this->connection);
$got_string = true;
} elseif (isset($result->result)) {
/*
* Probably received a result object.
* Extract the result resource identifier.
*/
$id = $result->result;
$got_string = false;
} else {
/*
* Probably received a result resource identifier.
* Copy it.
*/
$id = $result;
$got_string = false;
}
if (!is_resource($id)) {
return $this->ifxRaiseError(DB_ERROR_NEED_MORE_DATA);
}
$flds = @ifx_fieldproperties($id);
$count = @ifx_num_fields($id);
if (count($flds) != $count) {
return $this->raiseError("can't distinguish duplicate field names");
}
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
$case_func = 'strtolower';
} else {
$case_func = 'strval';
}
$i = 0;
$res = array();
if ($mode) {
$res['num_fields'] = $count;
}
foreach ($flds as $key => $value) {
$props = explode(';', $value);
$res[$i] = array('table' => $got_string ? $case_func($result) : '', 'name' => $case_func($key), 'type' => $props[0], 'len' => $props[1], 'flags' => $props[4] == 'N' ? 'not_null' : '');
if ($mode & DB_TABLEINFO_ORDER) {
$res['order'][$res[$i]['name']] = $i;
}
if ($mode & DB_TABLEINFO_ORDERTABLE) {
$res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
}
$i++;
}
// free the result only if we were called on a table
if ($got_string) {
@ifx_free_result($id);
}
return $res;
}
示例5: simpleQuery
/**
* Send a query to Informix and return the results as a
* Informix resource identifier.
*
* @param $query the SQL query
*
* @return int returns a valid Informix result for successful SELECT
* queries, DB_OK for other successful queries. A DB error code
* is returned on failure.
*/
function simpleQuery($query)
{
$this->last_query = $query;
if (preg_match('/(SELECT)/i', $query)) { //TESTME: Use !DB::isManip()?
// the scroll is needed for fetching absolute row numbers
// in a select query result
$result = @ifx_query($query, $this->connection, IFX_SCROLL);
} else {
$result = @ifx_query($query, $this->connection);
}
if (!$result) {
return $this->ifxraiseError();
}
$this->affected = ifx_affected_rows ($result);
// Determine which queries that should return data, and which
// should return an error code only.
if (preg_match('/(SELECT)/i', $query)) {
return $result;
}
return DB_OK;
}
示例6: rollback
/**
* Roll back (undo) the current transaction.
*/
function rollback()
{
if ($this->transaction_opcount > 0) {
$result = @ifx_query('ROLLBACK WORK', $this->connection);
$this->transaction_opcount = 0;
if (!$result) {
return $this->ifxRaiseError();
}
}
return DB_OK;
}
示例7: DoQuery
function DoQuery($query, $first = 0, $limit = 0, $free_non_select_result = 1, $prepared_query = 0)
{
ifx_nullformat(1);
ifx_blobinfile_mode(0);
$query = ltrim($query);
if (GetType($space = strpos($query, " ")) != "integer") {
$space = strlen($query);
}
$query_type = strtolower(substr($query, 0, $space));
if (($select = $query_type == "select") && $limit > 0) {
$query = substr($query, 0, $space) . " FIRST " . ($first + $limit) . " " . substr($query, strlen("select"));
$cursor_type = $first ? IFX_SCROLL : 0;
} else {
$cursor_type = 0;
}
if ($prepared_query && isset($this->query_parameters[$prepared_query]) && count($this->query_parameters[$prepared_query])) {
$result = $cursor_type ? @ifx_query($query, $this->connection, $cursor_type, $this->query_parameters[$prepared_query]) : @ifx_query($query, $this->connection, $this->query_parameters[$prepared_query]);
} else {
$result = $cursor_type ? @ifx_query($query, $this->connection, $cursor_type) : @ifx_query($query, $this->connection);
}
if ($result) {
$result_value = intval($result);
switch ($query_type) {
case "select":
$this->current_row[$result_value] = -1;
if ($limit > 0) {
$this->limits[$result_value] = array($first, $limit, 0);
}
$this->highest_fetched_row[$result_value] = -1;
break;
case "commit":
case "rollback":
case "begin":
case "database":
ifx_free_result($result);
break;
default:
$this->affected_rows = ifx_affected_rows($result);
if ($free_non_select_result) {
ifx_free_result($result);
}
break;
}
} else {
$this->SetIFXError("Do query", "Could not query Informix database");
}
return $result;
}
示例8: otherdb
//.........这里部分代码省略.........
$ifxquery = stripslashes($ifxquery);
print <<<END
<form method="POST" name="ifxform" action="?s=gg&db=ifx">
<div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px">
User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px">
Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br>
<script language="javascript">
function ifxFull(i){
Str = new Array(11);
\tStr[0] = "";
\tStr[1] = "select dbservername from sysobjects;";
\tStr[2] = "select name from sysdatabases;";
\tStr[3] = "select tabname from systables;";
\tStr[4] = "select colname from syscolumns where tabid=n;";
\tStr[5] = "select username,usertype,password from sysusers;";
\tifxform.ifxsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br>
<select onchange="return ifxFull(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>
\t<option value="4">hashes</option>
</select>
<input type="hidden" name="action" value="ifxquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($ifxaction == 'ifxquery') {
$ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg());
$ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg());
$ifxrow = ifx_fetch_row($ifxresult);
echo '<font face="verdana"><table border="1" cellpadding="1" cellspacing="2">' . "\n<tr>\n";
for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
echo '<td><b>' . ifx_fieldproperties($ifxresult) . "</b></td>\n";
}
echo "</tr>\n";
mysql_data_seek($ifxresult, 0);
while ($ifxrow = ifx_fetch_row($ifxresult)) {
echo "<tr>\n";
for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
echo '<td>' . "{$ifxrow[$i]}" . '</td>';
}
echo "</tr>\n";
}
echo "</table></font>";
ifx_free_result($ifxresult);
ifx_close();
}
} elseif ($db == "db2") {
$db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost';
$db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000';
$db2user = isset($_POST['db2user']) ? $_POST['db2user'] : 'root';
$db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '123456';
$db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql';
$db2action = isset($_POST['action']) ? $_POST['action'] : '';
$db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : '';
$db2query = stripslashes($db2query);
print <<<END
<form method="POST" name="db2form" action="?s=gg&db=db2">
<div class="actall">Host:<input type="text" name="db2host" value="{$db2host}" style="width:100px">
Port:<input type="text" name="db2port" value="{$db2port}" style="width:60px">
User:<input type="text" name="db2user" value="{$db2user}" style="width:100px">
示例9: db_query
function db_query($oCon, $sSQL)
{
return @ifx_query($sSQL, $oCon, IFX_SCROLL);
}
示例10: execWithBlobProcessing
/**
* Execute an SQL query with blob fields processing
* @param String sql
* @param Array blobs
* @param Array blobTypes
* @return Boolean
*/
public function execWithBlobProcessing($sql, $blobs, $blobTypes = array())
{
if (!count($blobs)) {
$this->exec($sql);
return;
}
$blobidarray = array();
foreach ($blobs as $fname => $fvalue) {
if (IsTextType($blobTypes[$fname])) {
$blob_type = 1;
} else {
$blob_type = 0;
}
$blobidarray[] = ifx_create_blob($blob_type, 0, $fvalue);
}
return @ifx_query($sql, $this->conn, $blobidarray);
}
示例11: otherdb
//.........这里部分代码省略.........
$ifxquery = stripslashes($ifxquery);
print <<<END
<form method="POST" name="ifxform" action="?s=w&db=ifx">
<div class="actall">Dbname:<input type="text" name="ifxhost" value="{$ifxdbname}" style="width:100px">
User:<input type="text" name="ifxuser" value="{$ifxuser}" style="width:100px">
Pass:<input type="text" name="ifxpass" value="{$ifxpass}" style="width:100px"><br><br>
<script language="javascript">
function ifxFull(i){
\tStr = new Array(11);
Str[0] = "";
\tStr[1] = "select dbservername from sysobjects;";
Str[2] = "select name from sysdatabases;";
Str[3] = "select tabname from systables;";
Str[4] = "select colname from syscolumns where tabid=n;";
Str[5] = "select username,usertype,password from sysusers;";
\tifxform.ifxsql.value = Str[i];
\treturn true;
}
</script>
<textarea name="ifxsql" style="width:600px;height:200px;">{$ifxquery}</textarea><br>
<select onchange="return ifxFull(options[selectedIndex].value)">
\t<option value="0" selected>command</option>
<option value="1">dbservername</option>
<option value="1">databases</option>
<option value="2">tables</option>
<option value="3">columns</option>
<option value="4">hashes</option>
</select>
<input type="hidden" name="action" value="ifxquery">
<input class="bt" type="submit" value="Query"></div></form>
END;
if ($ifxaction == 'ifxquery') {
$ifxlink = ifx_connect($ifcdbname, $ifxuser, $ifxpass) or die(ifx_errormsg());
$ifxresult = ifx_query($ifxquery, $ifxlink) or die(ifx_errormsg());
$ifxrow = ifx_fetch_row($ifxresult);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
echo "\n<tr>\n";
for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
echo '<td bgcolor="#228B22"><b>' . ifx_fieldproperties($ifxresult);
echo "</b></td>\n";
}
echo "</tr>\n";
mysql_data_seek($ifxresult, 0);
while ($ifxrow = ifx_fetch_row($ifxresult)) {
echo "<tr>\n";
for ($i = 0; $i < ifx_num_fields($ifxresult); $i++) {
echo '<td bgcolor="#B8B8E8">';
echo "{$ifxrow[$i]}";
echo '</td>';
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</font>";
ifx_free_result($ifxresult);
ifx_close();
}
} elseif ($db == "db2") {
$db2host = isset($_POST['db2host']) ? $_POST['db2host'] : 'localhost';
$db2port = isset($_POST['db2port']) ? $_POST['db2port'] : '50000';
$db2user = isset($_POST['db2user']) ? $_POST['db2user'] : 'root';
$db2pass = isset($_POST['db2pass']) ? $_POST['db2pass'] : '123456';
$db2dbname = isset($_POST['db2dbname']) ? $_POST['db2dbname'] : 'mysql';
$db2action = isset($_POST['action']) ? $_POST['action'] : '';
$db2query = isset($_POST['db2sql']) ? $_POST['db2sql'] : '';
示例12: _query
function _query($sql, $inputarr)
{
//sybase_free_result($this->_queryID);
$this->lastQuery = ifx_query($sql, $this->_connectionID);
if ($this->_autocommit) {
ifx_query('COMMIT', $this->_connectionID);
}
return $this->lastQuery;
}