本文整理汇总了PHP中cubrid_query函数的典型用法代码示例。如果您正苦于以下问题:PHP cubrid_query函数的具体用法?PHP cubrid_query怎么用?PHP cubrid_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cubrid_query函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: field_data
function field_data()
{
$retval = array();
$tablePrimaryKeys = array();
while ($field = cubrid_fetch_field($this->result_id)) {
$F = new stdClass();
$F->name = $field->name;
$F->type = $field->type;
$F->default = $field->def;
$F->max_length = $field->max_length;
$res = cubrid_query($this->conn_id, "SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table . "' AND is_primary_key = 'YES' AND index_name = 'pk_" . $field->table . "_" . $field->name . "'");
if ($res) {
$row = cubrid_fetch_array($res, CUBRID_NUM);
$F->primary_key = $row[0] > 0 ? 1 : null;
} else {
$F->primary_key = null;
}
if (is_resource($res)) {
cubrid_close_request($res);
$this->result_id = FALSE;
}
$retval[] = $F;
}
return $retval;
}
示例2: sql_query
function sql_query($query, $link = null)
{
global $NumQueries;
if (isset($link)) {
$result = cubrid_query($query, $link);
}
if (!isset($link)) {
$result = cubrid_query($query);
}
if ($result === false) {
output_error("SQL Error: " . sql_error(), E_USER_ERROR);
return false;
}
if ($result !== false) {
++$NumQueries;
return $result;
}
}
示例3: _execute
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
*/
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @cubrid_query($sql, $this->conn_id);
}
示例4: _execute
/**
* Execute the query
*
* @param string $sql an SQL query
* @return resource
*/
protected function _execute($sql)
{
return @cubrid_query($sql, $this->conn_id);
}
示例5: field_data
/**
* Field data
*
* Generates an array of objects containing field meta-data
*
* @access public
* @return array
*/
function field_data()
{
$retval = array();
$tablePrimaryKeys = array();
while ($field = cubrid_fetch_field($this->result_id)) {
$F = new stdClass();
$F->name = $field->name;
$F->type = $field->type;
$F->default = $field->def;
$F->max_length = $field->max_length;
// At this moment primary_key property is not returned when
// cubrid_fetch_field is called. The following code will
// provide a patch for it. primary_key property will be added
// in the next release.
// TODO: later version of CUBRID will provide primary_key
// property.
// When PK is defined in CUBRID, an index is automatically
// created in the db_index system table in the form of
// pk_tblname_fieldname. So the following will count how many
// columns are there which satisfy this format.
// The query will search for exact single columns, thus
// compound PK is not supported.
$res = cubrid_query($this->conn_id, "SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table . "' AND is_primary_key = 'YES' AND index_name = 'pk_" . $field->table . "_" . $field->name . "'");
if ($res) {
$row = cubrid_fetch_array($res, CUBRID_NUM);
$F->primary_key = $row[0] > 0 ? 1 : null;
} else {
$F->primary_key = null;
}
if (is_resource($res)) {
cubrid_close_request($res);
$this->result_id = FALSE;
}
$retval[] = $F;
}
return $retval;
}
示例6: query
public function query($query, $security = array())
{
$this->query = cubrid_query($query, $this->connect);
return $this->query;
}
示例7: values
#!/usr/bin/php
<?php
$sql = "insert into foo1 values(1,1)";
for ($i = 0; $i < 1; $i++) {
$con = @cubrid_connect("test-db-server", 33113, "testdb", "dba", "");
if ($con) {
$req = cubrid_query($sql, $con);
if ($req) {
echo "cubrid_query error";
}
while ($row = cubrid_fetch($req)) {
echo "to: \$ row [0], b: \$ row [1] \\ n";
}
if ($req) {
cubrid_close_request($req);
}
cubrid_disconnect($con);
} else {
echo "failed cubrid_connect . \\ n ";
sleep(1);
}
}
示例8: query
/**
* Main function for querying to database
*
* @param $query The SQL querey statement
* @return string|objet Return the resource id of query
*/
public function query($sql)
{
if (is_null($this->link)) {
$this->init();
}
$query = cubrid_query($sql, $this->link);
$this->lastQuery = $sql;
if ($this->lastError = cubrid_error($this->link)) {
if ($this->throwError) {
throw new \Exception($this->lastError);
} else {
$this->printError();
return false;
}
}
return $query;
}
示例9: query
function query($query)
{
// This keeps the connection alive for very long running scripts
if ($this->num_queries >= 500) {
$this->disconnect();
$this->connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost, $this->dbport);
}
// Initialise return
$return_val = 0;
// Flush cached values..
$this->flush();
// For reg expressions
$query = trim($query);
// Log how the function was called
$this->func_call = "\$db->query(\"{$query}\")";
// Keep track of the last query for debug..
$this->last_query = $query;
// Count how many queries there have been
$this->num_queries++;
// Start timer
$this->timer_start($this->num_queries);
// Use core file cache function
if ($cache = $this->get_cache($query)) {
// Keep tack of how long all queries have taken
$this->timer_update_global($this->num_queries);
// Trace all queries
if ($this->use_trace_log) {
$this->trace_log[] = $this->debug(false);
}
return $cache;
}
// If there is no existing database connection then try to connect
if (!isset($this->dbh) || !$this->dbh) {
$this->connect($this->dbuser, $this->dbpassword, $this->dbname, $this->dbhost, $this->dbport);
}
// Perform the query via std cubrid_query function..
$this->result = @cubrid_query($query, $this->dbh);
// If there is an error then take note of it..
if ($str = @cubrid_error($this->dbh)) {
$this->register_error($str);
$this->show_errors ? trigger_error($str, E_USER_WARNING) : null;
return false;
}
// Query was an insert, delete, update, replace
if (preg_match("/^(insert|delete|update|replace|truncate|drop|create|alter)\\s+/i", $query)) {
$is_insert = true;
$this->rows_affected = @cubrid_affected_rows($this->dbh);
// Take note of the insert_id
if (preg_match("/^(insert|replace)\\s+/i", $query)) {
$this->insert_id = @cubrid_insert_id($this->dbh);
}
// Return number fo rows affected
$return_val = $this->rows_affected;
} else {
$is_insert = false;
// Take note of column info
$i = 0;
while ($i < @cubrid_num_fields($this->result)) {
$this->col_info[$i] = @cubrid_fetch_field($this->result);
$i++;
}
// Store Query Results
$num_rows = 0;
while ($row = @cubrid_fetch_object($this->result)) {
// Store relults as an objects within main array
$this->last_result[$num_rows] = $row;
$num_rows++;
}
@cubrid_free_result($this->result);
// Log number of rows the query returned
$this->num_rows = $num_rows;
// Return number of rows selected
$return_val = $this->num_rows;
}
// disk caching of queries
$this->store_cache($query, $is_insert);
// If debug ALL queries
$this->trace || $this->debug_all ? $this->debug() : null;
// Keep tack of how long all queries have taken
$this->timer_update_global($this->num_queries);
// Trace all queries
if ($this->use_trace_log) {
$this->trace_log[] = $this->debug(false);
}
return $return_val;
}
示例10: mysql_query
<?php
mysql_query($res, <<<SQL
select {$a} from table
SQL
);
pg_query($res, "select {$a} from table ");
sqlsrv_query($res, "select " . $a . " from table ");
\cubrid_query($res, 'select ' . $a . ' from table ');
//sybase_query
//ingres_query
// OK, as no concatenation
mysqli_query($res, <<<SQL
select * from table
SQL
);
// Nowdoc
\ingres_query($res, <<<'SQL'
select * from table $table;
SQL
);