function free_result()
 {
     if (is_resource($this->result_id) || get_resource_type($this->result_id) == "Unknown" && preg_match('/Resource id #/', strval($this->result_id))) {
         cubrid_close_request($this->result_id);
         $this->result_id = FALSE;
     }
 }
Example #2
0
function check_table_existence($conn_handle, $table_name)
{
    $sql_stmt = "SELECT class_name FROM db_class WHERE class_name = ?";
    $cubrid_req = cubrid_prepare($conn_handle, $sql_stmt);
    if (!$cubrid_req) {
        return -1;
    }
    $cubrid_retval = cubrid_bind($cubrid_req, 1, $table_name);
    if (!$cubrid_req) {
        cubrid_close_request($cubrid_req);
        return -1;
    }
    $cubrid_retval = cubrid_execute($cubrid_req);
    if (!$cubrid_retval) {
        cubrid_close_request($cubrid_req);
        return -1;
    }
    $row_num = cubrid_num_rows($cubrid_req);
    if ($row_num < 0) {
        cubrid_close_request($cubrid_req);
        return -1;
    }
    cubrid_close_request($cubrid_req);
    if ($row_num > 0) {
        return 1;
    } else {
        return 0;
    }
}
Example #3
0
#!/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);
    }
}
Example #4
0
 public static function free($handle = null)
 {
     cubrid_close_request($handle);
 }
Example #5
0
 /**
  * Free the result.
  *
  * @return null
  */
 public function free_result()
 {
     if (is_resource($this->result_id) || get_resource_type($this->result_id) == 'Unknown' && preg_match('/Resource id #/', strval($this->result_id))) {
         cubrid_close_request($this->result_id);
         $this->result_id = false;
     }
 }
Example #6
0
 /**
  * Check column exist status of the table
  * @param string $table_name table name
  * @param string $column_name column name
  * @return boolean
  */
 function isColumnExists($table_name, $column_name)
 {
     $query = sprintf("select \"attr_name\" from \"db_attribute\" where " . "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name);
     $result = $this->_query($query);
     if (cubrid_num_rows($result) > 0) {
         $output = TRUE;
     } else {
         $output = FALSE;
     }
     if ($result) {
         cubrid_close_request($result);
     }
     return $output;
 }
Example #7
0
<?php

include_once "connect.inc";
header('Content-type: text/html; charset=euc-kr');
//var_dump($connect_url);
$conn = cubrid_connect_with_url($connect_url);
$sql = "SELECT a from foo";
$result = cubrid_execute($conn, $sql);
$pResult = cubrid_fetch($result);
echo $pResult[0];
echo "<br/>";
cubrid_close_request($result);
cubrid_rollback($conn);
cubrid_disconnect($conn);
Example #8
0
 /**
  * Get multiple records
  *
  * @param string $query The sql query
  * @param string $type return data type option. the default is "object"
  */
 public function results($query, $returnType = false)
 {
     $return = false;
     if ($returnType) {
         $this->returnType = $returnType;
     }
     if (is_null($query)) {
         $query = $this->command();
     }
     $result = $this->query($query);
     if ($this->returnType == 'object') {
         while ($row = cubrid_fetch_object($result, $this->instantiateClass)) {
             $return[] = $row;
         }
         cubrid_close_request($result);
         return $return;
     }
     if ($this->returnType == 'iterator') {
         return $result;
     }
     if ($this->returnType == 'array') {
         while ($row = cubrid_fetch_assoc($result)) {
             $return[] = $row;
         }
         cubrid_close_request($result);
         return $return;
     }
     return $return;
 }
Example #9
0
 protected function tearDown()
 {
     if ($this->error_flag) {
         echo "Req:" . $this->req;
         echo "Error Code: ", cubrid_error_code();
         echo "Error Facility: ", cubrid_error_code_facility();
         echo "Error Message: ", cubrid_error_msg();
     }
     if ($this->req) {
         cubrid_close_request($this->req);
     }
     if ($this->con) {
         cubrid_disconnect($this->con);
     }
     if (VERBOSE_OUTPUT == true) {
         echo "\r\nCleanup completed.";
     }
 }
Example #10
0
 /**
  * Get multiple records
  *
  * @param string $query The sql query
  * @param string $type return data type option. the default is "object"
  */
 public function results($query, $type = 'object')
 {
     if (is_null($query)) {
         $query = $this->command();
     }
     $result = $this->query($query);
     while ($row = cubrid_fetch_object($result, $this->instantiateClass)) {
         if ($type == 'array') {
             $return[] = (array) $row;
         } else {
             $return[] = $row;
         }
     }
     cubrid_close_request($result);
     if (!isset($return)) {
         return false;
     }
     return $return;
 }
Example #11
0
function sql_free_result($result)
{
    $fresult = cubrid_free_result($result);
    if ($fresult === false) {
        output_error("SQL Error: " . sql_error(), E_USER_ERROR);
        return false;
    }
    $fresult = cubrid_close_request($result);
    if ($fresult === false) {
        output_error("SQL Error: " . sql_error(), E_USER_ERROR);
        return false;
    }
    if ($fresult === true) {
        return true;
    }
}
Example #12
0
 /**
  * @brief 특정 테이블의 column의 정보를 return
  **/
 function isColumnExists($table_name, $column_name)
 {
     $query = sprintf("select * from db_attribute where attr_name ='%s' and class_name = '%s%s'", $column_name, $this->prefix, $table_name);
     $result = $this->_query($query);
     if (cubrid_num_rows($result) > 0) {
         $output = true;
     } else {
         $output = false;
     }
     if ($result) {
         cubrid_close_request($result);
     }
     return $output;
 }