Update of /cvsroot/phpmp/phpMP/dba
In directory usw-pr-cvs1:/tmp/cvs-serv3263/dba
Modified Files:
mysql.dba
Log Message:
Added MySQL DBA Layer.
Index: mysql.dba
===================================================================
RCS file: /cvsroot/phpmp/phpMP/dba/mysql.dba,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** mysql.dba 5 Nov 2002 22:11:05 -0000 1.17
--- mysql.dba 6 Nov 2002 03:28:19 -0000 1.18
***************
*** 1,5 ****
<?php
! // MySQL DB Layer.
?>
--- 1,185 ----
<?php
! class DB
! {
!
! var $ident_link;
! var $connected;
!
! connect ()
! {
! if ( empty ($this->ident_link) )
! {
! $connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWD);
!
! if ( !$connection )
! {
! $this->connected = 0;
! return 0;
! }
! else
! {
! $this->ident_link = $connection;
!
! $this->selectDB (DB_NAME, $connection);
! return $this->ident_link;
! }
! }
! else
! {
! return $this->ident_link;
! }
!
! }
!
! close ()
! {
! if ( $this->ident_link != 0 )
! {
! @mysql_close($this->ident_link);
! $this->ident_link = 0;
!
! return 1;
! }
! else
! {
! return 1;
! }
! }
!
! query ( $qry )
! {
! if ( $this->ident_link == 0 )
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! if ( !$db )
! {
! return 0;
! }
! else
! {
! $result = @mysql_query( $qry, $db );
! return $result;
! }
! }
!
! function selectDB ( $db_name ) {
!
! if ( $this->ident_link == 0 )
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! if (!$db)
! {
! return 0;
! }
! else
! {
! $result = @mysql_select_db($db_name, $db);
! return $result;
! }
! }
!
! function numRows ($query)
! {
! if ( $this->ident_link == 0 )
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! $num = @mysql_num_rows($query);
! return $num;
!
! }
!
! function insertID()
! {
! if($this->ident_link == 0)
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! $num = @mysql_insert_id($this->ident_link);
! return $num;
!
! }
!
! function result ( $result, $row=0, $field='' )
! {
! if($this->ident_link == 0)
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! $result = @mysql_result($result, $row, $field);
! return $result;
! }
!
! function fetchArray($query)
! {
! if($this->ident_link == 0)
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! return @mysql_fetch_array($query);
! }
!
! function fetchRow($query)
! {
! if ( $this->ident_link == 0 )
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! $result = @mysql_fetch_row($query);
! return $result;
! }
!
! function affectedRows() {
! if($this->ident_link == 0)
! {
! $db = $this->connect();
! }
! else
! {
! $db = $this->ident_link;
! }
!
! return @mysql_affected_rows($db);
! }
!
! }
?>
|