밑에 소스로 실행을 해봤는데요
데이타 잘 가져오고
echo 'close-commit' ; 문장도 출력이 되는데요
큐브리드 메니저에서 트렌젝션 정보에
계속 남아있던데 원래 그런건가요??
아님 코드를 잘못짠건가요???
<?php
include_once 'module.php' ;
//$resultObj = new CubridResult() ;
$DB = new CubridApi() ;
$DB->localConnect();
$q = 'select * from board_set' ;
$resultObj = $DB->query( $q ) ;
while( $a = $resultObj->fetch() )
{
print_r( $a ) ;
}
$q = 'select * from board' ;
$resultObj = $DB->query( $q ) ;
while( $a = $resultObj->fetch() )
{
print_r( $a ) ;
}
$DB->close();
?>
include_once 'module.php' ;
//$resultObj = new CubridResult() ;
$DB = new CubridApi() ;
$DB->localConnect();
$q = 'select * from board_set' ;
$resultObj = $DB->query( $q ) ;
while( $a = $resultObj->fetch() )
{
print_r( $a ) ;
}
$q = 'select * from board' ;
$resultObj = $DB->query( $q ) ;
while( $a = $resultObj->fetch() )
{
print_r( $a ) ;
}
$DB->close();
?>
module.php ----------------
<?php
class CubridApi{
private $conn ;
private $result ;
public function connect( $host , $user , $pwd , $name , $port )
{
$conn = cubrid_connect ($host , $port , $name , $user , $pwd );
if ($conn) {
$this->conn = $conn ;
}else{
echo "Error Code: ", cubrid_error_code ();
echo "Error Facility: ", cubrid_error_code_facility ();
echo "Error Message: ", cubrid_error_msg ();
debug_print_backtrace();
exit ;
}
}
public function localConnect()
{
$this->connect( "localhost" , "dba" , '' , "demodb" , 33000 );
}
public function close( $conn = '' )
{
if( empty($conn) ) $conn = $this->conn ;
if( $conn ) cubrid_disconnect( $conn ) ;
}
public function query( $sql )
{
$this->result = cubrid_execute($this->conn, $sql);
$CubridResult = new CubridResult( $this->conn , $this->result ) ;
return $CubridResult ;
}
public function fetch_test()
{
$a = cubrid_fetch ($this->result ) ;
print_r( $a ) ;
}
}
class CubridResult{
private $conn ;
private $result ;
public function __construct( $conn , $result )
{
$this->conn = $conn ;
$this->result = $result ;
}
public function fetch()
{
echo 'fetch-call' ;
if( $a = cubrid_fetch ($this->result ) )
{
echo 'fetch-return' ;
return $a ;
}else{
echo 'fetch-commit' ;
cubrid_commit ($this->conn);
$this->close() ;
return false ;
}
}
public function close()
{
cubrid_close_request($this->result) ;
if ($failed) {
echo 'close-rollback' ;
cubrid_rollback ($this->conn);
} else {
echo 'close-commit' ;
cubrid_commit ($this->conn);
}
}
}
?>
class CubridApi{
private $conn ;
private $result ;
public function connect( $host , $user , $pwd , $name , $port )
{
$conn = cubrid_connect ($host , $port , $name , $user , $pwd );
if ($conn) {
$this->conn = $conn ;
}else{
echo "Error Code: ", cubrid_error_code ();
echo "Error Facility: ", cubrid_error_code_facility ();
echo "Error Message: ", cubrid_error_msg ();
debug_print_backtrace();
exit ;
}
}
public function localConnect()
{
$this->connect( "localhost" , "dba" , '' , "demodb" , 33000 );
}
public function close( $conn = '' )
{
if( empty($conn) ) $conn = $this->conn ;
if( $conn ) cubrid_disconnect( $conn ) ;
}
public function query( $sql )
{
$this->result = cubrid_execute($this->conn, $sql);
$CubridResult = new CubridResult( $this->conn , $this->result ) ;
return $CubridResult ;
}
public function fetch_test()
{
$a = cubrid_fetch ($this->result ) ;
print_r( $a ) ;
}
}
class CubridResult{
private $conn ;
private $result ;
public function __construct( $conn , $result )
{
$this->conn = $conn ;
$this->result = $result ;
}
public function fetch()
{
echo 'fetch-call' ;
if( $a = cubrid_fetch ($this->result ) )
{
echo 'fetch-return' ;
return $a ;
}else{
echo 'fetch-commit' ;
cubrid_commit ($this->conn);
$this->close() ;
return false ;
}
}
public function close()
{
cubrid_close_request($this->result) ;
if ($failed) {
echo 'close-rollback' ;
cubrid_rollback ($this->conn);
} else {
echo 'close-commit' ;
cubrid_commit ($this->conn);
}
}
}
?>