/** * Field data * * Generates an array of objects containing field meta-data * * @return array */ public function field_data() { $retval = array(); for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) { $retval[$i] = new stdClass(); $retval[$i]->name = cubrid_field_name($this->result_id, $i); $retval[$i]->type = cubrid_field_type($this->result_id, $i); $retval[$i]->max_length = cubrid_field_len($this->result_id, $i); $retval[$i]->primary_key = (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE); } return $retval; }
public function columnData() { if (empty($this->query)) { return false; } $columns = array(); for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) { $columns[$i] = new stdClass(); $columns[$i]->name = cubrid_field_name($this->query, $i); $columns[$i]->type = cubrid_field_type($this->query, $i); $columns[$i]->maxLength = cubrid_field_len($this->query, $i); $columns[$i]->primaryKey = (int) (strpos(cubrid_field_flags($this->query, $i), 'primary_key') !== false); } return $columns; }
/** * @group arnia-wrong-parameters */ public function testCubridFieldFlags3() { 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_field_flags($this->req, -100); $this->assertTrue(FALSE, "Expected Exception not thrown."); } catch (Exception $e) { //echo $e->getMessage()."\r\n"; $this->assertEquals(-2006, cubrid_error_code()); $this->assertEquals(4, cubrid_error_code_facility()); $this->assertEquals('Invalid parameter', cubrid_error_msg()); } $this->deleteTestTable(); }