Ejemplo n.º 1
0
function cubrid_mysql_fetch_object($result)
{
    return cubrid_fetch_object($result);
}
Ejemplo n.º 2
0
 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @access private
  * @return object
  */
 function _fetch_object()
 {
     return cubrid_fetch_object($this->result_id);
 }
Ejemplo n.º 3
0
 /**
  * Result - object
  *
  * Returns the result set as an object
  *
  * @param    string $class_name
  * @return    object
  */
 protected function _fetch_object($class_name = 'stdClass')
 {
     return cubrid_fetch_object($this->result_id, $class_name);
 }
Ejemplo n.º 4
0
 /**
  * Get single record
  *
  * @param string $query The sql query
  * @param string $type return data type option. the default is "object"
  */
 public function row($query, $returnType = false)
 {
     if ($returnType) {
         $this->returnType = $returnType;
     }
     if (is_null($query)) {
         $query = $this->command();
     }
     if (is_null($this->link)) {
         $this->init();
     }
     $result = $this->query($query);
     $return = cubrid_fetch_object($result, $this->instantiateClass);
     if ($this->returnType == 'object') {
         return $return;
     }
     return (array) $return;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 /**
  * @group arnia
  */
 public function testCubridDataSeek1()
 {
     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_data_seek($this->req, 1);
         $valobj = cubrid_fetch_object($this->req);
         $this->assertEquals(22, $valobj->column_integer);
     } catch (Exception $e) {
         $this->log = __FUNCTION__;
         self::writeErrorLog($e);
         $this->assertTrue(TRUE);
     }
     $this->deleteTestTable();
 }
Ejemplo n.º 7
0
    {
        $this->c1 = $s;
        $this->c2 = $f;
    }
}
printf("cubrid_fetch_object(res, string ,array) cubrid_fetch_object_construct start1\n");
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_construct', null));
printf("start2:\n");
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_construct', array('c1')));
printf("start3:\n");
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_construct', array('c1', 'c2')));
printf("start4:\n");
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_construct', array('c1', 'c2', 'c3')));
class cubrid_fetch_object_private_construct
{
    private function __construct($s, $f)
    {
        var_dump($s);
    }
}
printf("cubrid_fetch_object(res, string ,array) cubrid_fetch_object_private_construct start1\n");
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_private_construct', array('c1', 'c2')));
printf("start5:\n");
var_dump(cubrid_fetch_object($res));
printf("start6:\n");
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_construct', array('c1', 'c2')));
// Fatal error, script execution will end
printf("start6:\n");
var_dump(cubrid_fetch_object($res, 'this_class_does_not_exist'));
cubrid_disconnect($conn);
print "Finished!\n";