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; }
/** * 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; }
public function fetchArray() { if (!empty($this->query)) { return cubrid_fetch_array($this->query); } else { return false; } }
function sql_fetch_array($result, $result_type = CUBRID_BOTH) { $row = cubrid_fetch_array($result, $result_type); return $row; }