Example #1
0
 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * @group arnia-wrong-parameters
  */
 public function testCubridFieldLen3()
 {
     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);
         $len = cubrid_field_len(-1, 0);
         $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();
 }