当前位置: 首页>>代码示例>>PHP>>正文


PHP cubrid_fetch_field函数代码示例

本文整理汇总了PHP中cubrid_fetch_field函数的典型用法代码示例。如果您正苦于以下问题:PHP cubrid_fetch_field函数的具体用法?PHP cubrid_fetch_field怎么用?PHP cubrid_fetch_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cubrid_fetch_field函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:pepegarcia,项目名称:publicidadoficialdemo-1,代码行数:25,代码来源:cubrid_result.php

示例2: 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;
	}
开发者ID:Opmantek,项目名称:open-audit,代码行数:62,代码来源:cubrid_result.php

示例3: field_data

 /**
  * Field data
  *
  * Generates an array of objects containing field meta-data
  *
  * @return	array
  */
 public function field_data()
 {
     $retval = array();
     $i = 0;
     while ($field = cubrid_fetch_field($this->result_id)) {
         $retval[$i] = new stdClass();
         $retval[$i]->name = $field->name;
         // CUBRID returns type as e.g. varchar(100),
         // so we need to remove all digits and brackets.
         $retval[$i]->type = preg_replace('/[\\d()]/', '', $field->type);
         $retval[$i]->default = $field->def;
         // Use CUBRID's native API to obtain column's max_length,
         // otherwise $field->max_length has incorrect info
         $retval[$i]->max_length = cubrid_field_len($this->result_id, $i);
         $retval[$i++]->primary_key = $field->primary_key;
     }
     return $retval;
 }
开发者ID:aeduc,项目名称:mideteed,代码行数:25,代码来源:cubrid_result.php

示例4: cubrid_mysql_fetch_field

function cubrid_mysql_fetch_field($result)
{
    return cubrid_fetch_field($result);
}
开发者ID:vishalmuns,项目名称:sqlscripter,代码行数:4,代码来源:cubrid_mysql_compat.php

示例5: 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;
 }
开发者ID:m-osama,项目名称:astm,代码行数:86,代码来源:ez_sql_cubrid.php

示例6: testCubridFetchField4

 /**
  * @group arnia-wrong-parameters
  */
 public function testCubridFetchField4()
 {
     if (OUTPUT_FUNCTION_NAME == true) {
         echo "\r\nRunning: " . __FUNCTION__ . " = ";
     }
     try {
         $this->assertTrue($this->createTestTable(), "Failed to create the test table.");
         $this->sql = "SELECT * FROM test_table";
         $this->req = cubrid_execute($this->con, $this->sql);
         $val = cubrid_fetch_field($this->req, 100);
         $this->assertTrue(FALSE, "Expected Exception not thrown.");
     } catch (Exception $e) {
         //echo $e->getMessage()."\r\n";
         $this->assertEquals(0, cubrid_error_code());
         $this->assertEquals(0, cubrid_error_code_facility());
         $this->assertEquals('', cubrid_error_msg());
     }
     $this->deleteTestTable();
 }
开发者ID:CUBRID,项目名称:cubrid-php,代码行数:22,代码来源:cubrid.php


注:本文中的cubrid_fetch_field函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。