Exemple #1
0
function __tcSqlLogEnd($result, $cachedResult = 0)
{
    global $__tcSqlLog, $__tcSqlQueryBeginTime, $__tcSqlLogCount, $__tcPageStartTime;
    static $client_encoding = '';
    $tcSqlQueryEndTime = explode(' ', microtime());
    $elapsed = $tcSqlQueryEndTime[1] - $__tcSqlQueryBeginTime[1] + ($tcSqlQueryEndTime[0] - $__tcSqlQueryBeginTime[0]);
    //	if( !$client_encoding ) {
    //		$client_encoding = str_replace('_','-',cubrid_client_encoding());
    //	}
    $client_encoding = 'utf-8';
    //	if( $client_encoding != 'utf8' && function_exists('iconv') ) {
    //		$__tcSqlLog[$__tcSqlLogCount]['error'] = iconv( $client_encoding, 'utf-8', mysql_error());
    //	}
    //	else {
    $__tcSqlLog[$__tcSqlLogCount]['error'] = iconv('euc-kr', 'utf-8', cubrid_error_msg());
    //	}
    $__tcSqlLog[$__tcSqlLogCount]['errno'] = cubrid_error_code();
    if ($cachedResult == 0) {
        $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = ceil($elapsed * 10000) / 10;
    } else {
        $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = 0;
    }
    $__tcSqlLog[$__tcSqlLogCount]['elapsed'] = sprintf("%4.1f", $__tcSqlLog[$__tcSqlLogCount]['elapsed']);
    $__tcSqlLog[$__tcSqlLogCount]['cached'] = $cachedResult;
    $__tcSqlLog[$__tcSqlLogCount]['rows'] = 0;
    $__tcSqlLog[$__tcSqlLogCount]['endtime'] = $tcSqlQueryEndTime[1] - $__tcPageStartTime[1] + ($tcSqlQueryEndTime[0] - $__tcPageStartTime[0]);
    $__tcSqlLog[$__tcSqlLogCount]['endtime'] = sprintf("%4.1f", ceil($__tcSqlLog[$__tcSqlLogCount]['endtime'] * 10000) / 10);
    if (!$cachedResult && cubrid_error_code() == 0) {
        switch (strtolower(substr($__tcSqlLog[$__tcSqlLogCount]['sql'], 0, 6))) {
            case 'select':
                $__tcSqlLog[$__tcSqlLogCount]['rows'] = cubrid_num_rows($result);
                break;
            case 'insert':
            case 'delete':
            case 'update':
                $__tcSqlLog[$__tcSqlLogCount]['rows'] = cubrid_affected_rows($result);
                break;
        }
    }
    $__tcSqlLogCount++;
    $__tcSqlQueryBeginTime = 0;
}
function cubrid_mysql_errno($link_identifier = '')
{
    // int mysql_errno ( [resource link_identifier] )
    return cubrid_error_code();
}
Exemple #3
0
require_once 'connectLarge.inc';
require_once 'until.php';
if (!($conn = cubrid_connect($host, $port, $db, $user, $passwd))) {
    printf("Cannot connect to db server using host=%s, port=%d, dbname=%s, user=%s, passwd=***\n", $host, $port, $db, $user);
    exit(1);
}
$retval = check_table_existence($conn, "largetable");
if ($retval == -1) {
    exit(1);
} elseif ($retval == 1) {
    printf("this table is created\n");
} else {
    printf("#####start: create largetable#####\n");
    $cubrid_req = cubrid_execute($conn, "CREATE TABLE largetable(a int AUTO_INCREMENT, b clob)");
    if (!$cubrid_req) {
        printf("Failed to create test table: [%d] %s\n", cubrid_error_code(), cubrid_error_msg());
        exit(1);
    }
    $req = cubrid_prepare($conn, "insert into largetable(b) values (?)");
    $importName = array("largeFile/large.txt");
    for ($i = 0; $i < count($importName); $i++) {
        $lob = cubrid_lob2_new($conn, "CLOB");
        cubrid_lob2_import($lob, $importName[$i]);
        cubrid_lob2_bind($req, 1, $lob, "CLOB");
        cubrid_execute($req);
        cubrid_lob2_close($lob);
    }
    cubrid_close_prepare($req);
    if (!cubrid_commit($conn)) {
        exit(1);
    }
Exemple #4
0
 /**
  * Retrieve CUBRID error and set to object
  *
  * @author Corina Udrescu (dev@xpressengine.org)
  */
 function _setError()
 {
     $code = cubrid_error_code();
     $msg = cubrid_error_msg();
     $this->setError($code, $msg);
 }
Exemple #5
0
if ($is_exist === true) {
    $result = cubrid_execute($dh, "DROP TABLE \"" . $db["table"] . "\";");
    if ($result === false) {
        printf("DB Error %d (%d): %s\n", cubrid_error_code(), cubrid_error_code_facility(), cubrid_error_msg());
        cubrid_rollback($dh);
        cubrid_disconnect($dh);
        exit(0);
    }
    cubrid_close_request($result);
    cubrid_commit($dh);
    $is_exist = false;
}
if ($is_exist === false) {
    $result = cubrid_execute($dh, "CREATE TABLE \"" . $db["table"] . "\" (\n         \"index\"   INTEGER NOT NULL,\n         \"addr1\"   CHARACTER VARYING(12) NOT NULL,\n         \"addr2\"   CHARACTER VARYING(30) NOT NULL,\n         \"addr3\"   CHARACTER VARYING(64) NOT NULL,\n         \"addr4\"   CHARACTER VARYING(24) NOT NULL,\n         \"zipcode\" CHARACTER(7) NOT NULL\n       );");
    if ($result === false) {
        printf("DB Error %d (%d): %s\n", cubrid_error_code(), cubrid_error_code_facility(), cubrid_error_msg());
        cubrid_rollback($dh);
        cubrid_disconnect($dh);
        exit(0);
    }
    cubrid_close_request($result);
    cubrid_commit($dh);
    $result = cubrid_execute($dh, "CREATE UNIQUE INDEX \"" . $db["table"] . "_idx\"\n         ON \"" . $db["table"] . "\" (\"index\" ASC);");
    if ($result === false) {
        printf("Cannot create index.\n");
        cubrid_rollback($dh);
    } else {
        cubrid_close_request($result);
        cubrid_commit($dh);
    }
}
 public function getErrorNo()
 {
     return cubrid_error_code();
 }
Exemple #7
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.";
     }
 }
Exemple #8
0
function sql_errno($link = null)
{
    $result = cubrid_error_code();
    return $result;
}
 /**
  * @brief : 쿼리문의 실행 및 결과의 fetch 처리
  *
  * query : query문 실행하고 result return\n
  * fetch : reutrn 된 값이 없으면 NULL\n
  *         rows이면 array object\n
  *         row이면 object\n
  *         return\n
  **/
 function _query($query)
 {
     //echo "(((".$this->backtrace().")))";
     if (!$query || !$this->isConnected()) {
         return;
     }
     // 쿼리 시작을 알림
     $this->actStart($query);
     // 쿼리 문 실행
     $result = @cubrid_execute($this->fd, $query);
     // 오류 체크
     if (cubrid_error_code()) {
         $this->setError(cubrid_error_code(), cubrid_error_msg());
     }
     // 쿼리 실행 종료를 알림
     $this->actFinish();
     // 결과 리턴
     return $result;
 }
Exemple #10
0
$conn = cubrid_connect($host, $port, $db, $user, $passwd);
cubrid_execute($conn, "drop table if exists fetch_object_tb");
cubrid_execute($conn, "CREATE TABLE fetch_object_tb(c1 string, c2 char(20), c3 int, c4 double, c5 time, c6 date)");
cubrid_execute($conn, "insert into fetch_object_tb values('string1','char11111',1,11.11,TIME '02:10:22',DATE '08/14/1977')");
cubrid_execute($conn, "insert into fetch_object_tb values('string2','char2',2,222222,TIME '1:15',DATE '00-10-31')");
cubrid_execute($conn, "insert into fetch_object_tb values('string4','char4',4,44,TIME '4:15',DATE '04-10-21')");
cubrid_execute($conn, "insert into fetch_object_tb values('string3','char3',3,33,TIME '3:15',DATE '03-10-31')");
cubrid_execute($conn, "insert into fetch_object_tb values('string5','char5',5,55,TIME '5:15',DATE '05-10-01')");
cubrid_execute($conn, "insert into fetch_object_tb values('string6','char6',6,66,TIME '6:15',DATE '06-10-11')");
cubrid_execute($conn, "insert into fetch_object_tb values('string7','char7',7,77,TIME '7:15',DATE '07-10-11')");
cubrid_execute($conn, "insert into fetch_object_tb values('string8','char8',8,88,TIME '8:15',DATE '08-10-11')");
cubrid_execute($conn, "insert into fetch_object_tb values('string9','char9',9,99,TIME '9:15',DATE '09-10-11')");
cubrid_execute($conn, "insert into fetch_object_tb values('string10','char10',10,1010,TIME '10:15',DATE '010-10-11')");
$res = cubrid_execute($conn, "SELECT * FROM fetch_object_tb order by c1");
if (!$res) {
    printf("[003] [%d] %s\n", cubrid_error_code(), cubrid_error_msg());
    exit(1);
}
printf("cubrid_fetch_object(res) start\n");
var_dump(cubrid_fetch_object($res));
class cubrid_fetch_object_test
{
    public $c1 = NULL;
    public $c2 = NULL;
    public function toString()
    {
        var_dump($this);
    }
}
var_dump(cubrid_fetch_object($res, 'cubrid_fetch_object_test'));
class cubrid_fetch_object_construct extends cubrid_fetch_object_test