[phpMP-CVS] CVS: phpMP/core/dba firebird.php,1.1,1.2 mysql.php,1.16,1.17 postgresql.php,1.5,1.6
Status: Pre-Alpha
Brought to you by:
heimidal
|
From: Adam A. <ra...@us...> - 2003-10-09 05:37:52
|
Update of /cvsroot/phpmp/phpMP/core/dba
In directory sc8-pr-cvs1:/tmp/cvs-serv8299/core/dba
Modified Files:
firebird.php mysql.php postgresql.php
Log Message:
Final commits for the night, fixed some small issues with mysql and pgsql, initial checkin of Firebase API (really is far from complete, just putting in what I could do on first glance)
Index: firebird.php
===================================================================
RCS file: /cvsroot/phpmp/phpMP/core/dba/firebird.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** firebird.php 14 Sep 2003 21:09:11 -0000 1.1
--- firebird.php 9 Oct 2003 05:37:46 -0000 1.2
***************
*** 22,25 ****
*
*/
!
! ?>
\ No newline at end of file
--- 22,258 ----
*
*/
!
! // Firebird 1.x Database API
!
! class sql_db
! {
! var $db_connection_id;
! var $db_query;
! var $db_query_result = 0;
! var $db_query_count = 0;
! var $db_rowset = array();
!
! // Open database connection, select database
! function sql_connect($hostname, $port, $username, $password, $database, $persistant = NULL, $error_handling = NULL )
! {
! $db_path = $hostname.":".$database;
!
! if( !is_null($this->persistant) )
! {
! $this->db_connection_id = @ibase_pconnect($db_path, $username, $password);
! }
! else
! {
! $this->db_connection_id = @ibase_connect($db_path, $username, $password);
!
! }
!
! if( !$this->db_connection_id )
! {
! if( !is_null($error_handling) )
! {
! // to db error handler (ERROR_FLAG, $this->sql_error($this->db_connection_id), $this->sql_errno($this->db_connection_id));
! }
! else
! {
! return false;
! }
! }
!
! return $this->db_connection_id;
! }
!
! function sql_close($db_connect_id = NULL)
! {
! if( is_null($db_connect_id) )
! {
! $db_connect_id = $this->db_connection_id;
! }
!
! if($db_connect_id != FALSE)
! {
! if($this->db_query_result)
! {
! @$this->sql_free_result($this->db_query_result);
! }
!
! return @ibase_close($db_connect_id);
! }
! }
!
! // Query database
! // If you pass no query, it will try to execute the last query again
! function sql_query($sql = '', $sql_explain = NULL, $line = NULL, $file = NULL )
! {
! $this->sql_free_result($this->db_query_result); // remove previous query result
!
! if( !empty($sql) )
! {
! $this->db_query = $sql;
! }
!
! $this->db_query_count++;
!
! $this->db_query_result = @ibase_query($this->db_connection_id, $this->db_query);
!
! if( $this->db_query_result)
! {
! unset($this->db_rowset[$this->db_query_result]);
! return $this->db_query_result;
! }
! else
! {
! if( !is_null($sql_explain) )
! {
! // to db error handler (ERROR_FLAG, $this->sql_error($this->db_connection_id), $this->sql_errno($this->db_connection_id), $sql_explain, $line, $file);
! }
! else
! {
! return false;
! }
! }
! }
!
! // Select a row as an Associative, Numeric or Both (array)
! function sql_fetch_row($db_query_id = NULL, $row = NULL, $type = 'ASSOC')
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! switch($type)
! {
! case 'NUM':
! return @ibase_fetch_row($db_query_id);
! case 'ASSOC':
! default:
! return @ibase_fetch_assoc($db_query_id, $type);
! }
! }
!
! // Select all rows in one big array
! function sql_fetch_rowset($db_query_id = NULL, $type = 'ASSOC')
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! unset($this->db_rowset[$this->db_query_result]);
!
! $this->db_rowset[$this->db_query_result] = Array();
!
! while( $row = $this->sql_fetch_row($db_query_id, NULL, $type) )
! {
! $this->db_rowset[$this->db_query_result][] = $row;
! }
!
! return $this->db_rowset[$this->db_query_result];
! }
!
! // Number of rows from the last select query. Shouldn't be used for
! // Firebird compatability (hopefully an ibase_num_rows function will
! // be soon)
! function sql_num_rows($db_query_id = NULL)
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! // VOID for now
! }
!
! // Get last ID generated from an INSERT query
! function sql_insert_id($db_query_id = NULL)
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! // VOID for now
! }
!
! // Free result resource
! function sql_free_result($db_query_id = NULL)
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! unset($this->db_rowset[$db_query_id]);
!
! return @ibase_free_result($db_query_id);
! }
!
! // Number of fields selected in last query
! function sql_num_fields($db_query_id = NULL)
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! return @ibase_num_fields($db_query_id);
! }
!
! // Name of a specific field from a result
! function sql_field_name($db_query_id = NULL, $field_offset)
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! // VOID for now
! }
!
! // Field type from a result
! function sql_field_type($db_query_id = NULL, $field_offset)
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! // VOID for now
! }
!
! // Amount of rows affected in last query
! function sql_affected_rows()
! {
! if( is_null($db_query_id) )
! {
! $db_query_id = $this->db_query_result;
! }
!
! // VOID for now
! }
!
! // SQL Error message from connection
! function sql_error($db_connection_id = NULL)
! {
! if( is_null($db_connection_id) )
! {
! $db_connection_id = $this->db_connect_id;
! }
!
! return @ibase_errmsg($db_connection_id);
! }
!
! // SQL Error number from connection
! function sql_errno($db_connection_id = NULL)
! {
! if( is_null($db_connection_id) )
! {
! $db_connection_id = $this->db_connect_id;
! }
!
! // VOID for now
! }
! } // End of sql_db
!
! ?>
\ No newline at end of file
Index: mysql.php
===================================================================
RCS file: /cvsroot/phpmp/phpMP/core/dba/mysql.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** mysql.php 9 Oct 2003 05:16:37 -0000 1.16
--- mysql.php 9 Oct 2003 05:37:46 -0000 1.17
***************
*** 37,45 ****
if( !is_null($this->persistant) )
{
! $this->db_connection_id = @mysql_pconnect($this->hostname, $this->username, $this->password);
}
else
{
! $this->db_connection_id = @mysql_connect($this->hostname, $this->username, $this->password);
}
--- 37,45 ----
if( !is_null($this->persistant) )
{
! $this->db_connection_id = @mysql_pconnect($host, $username, $password);
}
else
{
! $this->db_connection_id = @mysql_connect($host, $username, $password);
}
***************
*** 58,62 ****
else
{
! if(! empty($this->database))
{
if( !is_null($error_handling) )
--- 58,64 ----
else
{
! $db_select = @mysql_select_db($database, $this->db_connection_id);
!
! if( !$db_select )
{
if( !is_null($error_handling) )
***************
*** 148,152 ****
$this->db_rowset[$this->db_query_result] = Array();
! while( $row = @this->sql_fetch_row($db_query_id, NULL, $type) )
{
$this->db_rowset[$this->db_query_result][] = $row;
--- 150,154 ----
$this->db_rowset[$this->db_query_result] = Array();
! while( $row = $this->sql_fetch_row($db_query_id, NULL, $type) )
{
$this->db_rowset[$this->db_query_result][] = $row;
Index: postgresql.php
===================================================================
RCS file: /cvsroot/phpmp/phpMP/core/dba/postgresql.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** postgresql.php 9 Oct 2003 05:16:37 -0000 1.5
--- postgresql.php 9 Oct 2003 05:37:46 -0000 1.6
***************
*** 56,59 ****
--- 56,61 ----
}
}
+
+ return $this->db_connection_id;
}
|