• Main Page
  • Data Structures
  • Files
  • File List

sybaseConnection.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * Sybase ASE database connection class
00005  *
00006  * @package objSQL
00007  * @version 2.1.0
00008  * @author MT Jordan <mtjo62@gmail.com>
00009  * @link http://objsql.sourceforge.net
00010  * @copyright 2004-2010 openSource Partners
00011  * @license LGPL
00012  * @revision $Id: sybaseConnection.php,v 1.7 2008-01-30 21:37:20-05 mt_jordan Exp $
00013  */
00014 
00015 class sybaseConnection
00016 {
00017    /**********************************************
00018     * Internal variables
00019     *********************************************/
00020 
00021    /**
00022      * Database connection object
00023      *
00024      * @access private
00025      * @var    mixed
00026      */
00027     private $objConnection;
00028 
00029    /**
00030      * Database connection information
00031      *
00032      * @access private
00033      * @var    array
00034      */
00035     private $objDatasource;
00036 
00037     /**********************************************
00038      * Class methods
00039      *********************************************/
00040 
00041     /**
00042      * Constructor
00043      *
00044      * @access public
00045      * @param  array $datasource
00046      */
00047     public function __construct( $datasource )
00048     {
00049         $this->objDatasource    = $datasource;
00050         $this->objDatasource[5] = ( array_key_exists( 5, $this->objDatasource ) && $this->objDatasource[5] ) ? true : false;
00051     }
00052 
00053     /**
00054      * Connect to database server
00055      *
00056      * @access public
00057      * @return mixed
00058      */
00059     public function objDbConnection()
00060     {
00061         //set higher levels to counteract random connection errors
00062         //php_sybase_ct.dll/server/PHP5 bug?
00063         sybase_min_client_severity( 100 );
00064         sybase_min_server_severity( 100 );
00065 
00066         $this->objConnection = ( $this->objDatasource[5] ) ? sybase_pconnect( $this->objDatasource[1], $this->objDatasource[2], $this->objDatasource[3] )
00067                                                            : sybase_connect( $this->objDatasource[1], $this->objDatasource[2], $this->objDatasource[3] );
00068 
00069         if ( $this->objConnection )
00070             //this may or may not be ignored - database is coupled with schema/server/user/pass
00071             sybase_select_db( $this->objDatasource[4], $this->objConnection );
00072         else
00073             trigger_error( sybase_get_last_message(), E_USER_WARNING );
00074 
00075         return $this->objConnection;
00076     }
00077 
00078     /**
00079      * Close connection to database server
00080      *
00081      * @access public
00082      * @return bool
00083      */
00084     public function objDbClose()
00085     {
00086         return sybase_close( $this->objConnection );
00087     }
00088 
00089     /**
00090      * Return info on database server
00091      *
00092      * @access public
00093      * @return str
00094      */
00095     public function objServerVersion()
00096     {
00097         $objStmt   = sybase_query( 'SELECT @@VERSION' );
00098         $objResult = sybase_fetch_row( $objStmt );
00099         sybase_free_result( $objStmt );
00100 
00101         return $objResult[0];
00102     }
00103 }
00104 
00105 ?>

Generated on Sat Jul 10 2010 15:14:39 for objSQL 2.1.0 by  doxygen 1.7.1