[Openfirst-cvscommit] base/config dbase.php,1.16,1.17
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2005-01-06 22:01:18
|
Update of /cvsroot/openfirst/base/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26916/config Modified Files: dbase.php Log Message: Finally fixed the bad branch issue. Index: dbase.php =================================================================== RCS file: /cvsroot/openfirst/base/config/dbase.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** dbase.php 29 Dec 2004 02:45:10 -0000 1.16 --- dbase.php 6 Jan 2005 22:01:07 -0000 1.17 *************** *** 26,33 **** // without having to be completely rewritten or released as two // different versions. ! $lastquery = ""; //Used for debugging if(isset($dbasetype) == false) { $dbasetype = "mysql"; } ! ! $connections = array(0 => array('conn' => NULL, 'res' => NULL, 'db' => NULL)); $connectdsn = ""; --- 26,32 ---- // without having to be completely rewritten or released as two // different versions. ! $lastquery; if(isset($dbasetype) == false) { $dbasetype = "mysql"; } ! $connectdsn = ""; *************** *** 35,39 **** // Include the PEAR Database Abstraction Layer include_once("DB.php"); - echo "PEAR is being used<br />\n"; } elseif(! isset($peardb)) { $peardb = false; --- 34,37 ---- *************** *** 42,50 **** // Wrapper for database selection. function ofirst_dbconnect($server = "", $username = "", $password = "", ! $newlink = "", $intclientflags = "", $ID = 0) { ! global $connections, $dbasetype, $peardb; if($peardb) { ! $connections[$ID] = "$dbasetype://$username:$password@$server/"; ! return($ID); } elseif($dbasetype == "mysql") { if(function_exists("mysql_connect") == false) { --- 40,48 ---- // Wrapper for database selection. function ofirst_dbconnect($server = "", $username = "", $password = "", ! $newlink = "", $intclientflags = "") { ! global $dbasetype, $peardb, $connectdsn; if($peardb) { ! $connectdsn = "$dbasetype://$username:$password@$server/"; ! return(0); } elseif($dbasetype == "mysql") { if(function_exists("mysql_connect") == false) { *************** *** 52,60 **** } if($intclientflags != "") { ! $connections[$ID]['conn'] = mysql_connect($server, $username, $password, $newlink, $intclientflags); } elseif($newlink != "") { ! $connections[$ID]['conn'] = mysql_connect($server, $username, $password, $newlink); } else { ! $connections[$ID]['conn'] = mysql_connect($server, $username, $password); } } elseif ($dbasetype == "mssql") { --- 50,58 ---- } if($intclientflags != "") { ! return(mysql_connect($server, $username, $password, $newlink, $intclientflags)); } elseif($newlink != "") { ! return(mysql_connect($server, $username, $password, $newlink)); } else { ! return(mysql_connect($server, $username, $password)); } } elseif ($dbasetype == "mssql") { *************** *** 62,66 **** die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } ! $connections[$ID]['conn'] = mssql_connect($server, $username, $password); } elseif ($dbasetype == "odbc") { if(function_exists("odbc_connect") == false) { --- 60,64 ---- die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } ! return(mssql_connect($server, $username, $password)); } elseif ($dbasetype == "odbc") { if(function_exists("odbc_connect") == false) { *************** *** 68,128 **** } if($newlink != "") { ! $connections[$ID]['conn'] = odbc_connect($server, $username, $password, $newlink); } else { ! $connections[$ID]['conn'] = odbc_connect($server, $username, $password); } } ! return $ID; } ! function ofirst_select_db($databasename, $ID = 0) { ! global $connections, $dbasetype, $peardb; ! $connections[$ID]['db'] = $databasename; if($peardb) { ! $connections[$ID]['conn'] = $connections[$ID]['conn'] =& DB::connect($connections[$ID]['conn'].$databasename); ! ! if (DB::isError ($connections[$ID])) ! return FALSE; } elseif($dbasetype == "mysql") { if(function_exists("mysql_select_db") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(mysql_select_db($databasename, $connections[$ID]['conn'])); ! /* } else { return(mysql_select_db($databasename)); ! }*/ } elseif ($dbasetype == "mssql") { if(function_exists("mssql_select_db") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(mssql_select_db($databasename, $connections[$ID]['conn'])); ! /* } else { return(mssql_select_db($databasename)); ! / }*/ ! } elseif ($dbasetype == "odbc") { ! // ODBC doesn't require selecting a DB ! return TRUE; } } ! function ofirst_dberrno($ID = 0) { ! global $connections, $dbasetype, $peardb; if($peardb) { ! // if($linkidentifier != "") { ! return(DB_Error::getCode($connections[$ID]['conn'])); #FIXME: Use last return ! /* } else { return(DB_Error::getCode()); ! }*/ } elseif($dbasetype == "mysql") { if(function_exists("mysql_errno") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(mysql_errno($connections[$ID]['conn'])); ! /* } else { return(mysql_errno()); ! }*/ } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { --- 66,121 ---- } if($newlink != "") { ! return(odbc_connect($server, $username, $password, $newlink)); } else { ! return(odbc_connect($server, $username, $password)); } } ! exit(0); } ! function ofirst_select_db($databasename, $linkidentifier = "") { ! global $dbasetype, $peardb, $connectdsn; if($peardb) { ! return($connectdsn =& DB::connect("$connectdsn$databasename")); } elseif($dbasetype == "mysql") { if(function_exists("mysql_select_db") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! if($linkidentifier != "") { ! return(mysql_select_db($databasename, $linkidentifier)); ! } else { return(mysql_select_db($databasename)); ! } } elseif ($dbasetype == "mssql") { if(function_exists("mssql_select_db") == false) { die("Microsoft SQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable Microsoft SQL support, or choose another database type."); } ! if($linkidentifier != "") { ! return(mssql_select_db($databasename, $linkidentifier)); ! } else { return(mssql_select_db($databasename)); ! } ! //ODBC does not require slecting a DB } + exit(0); } ! function ofirst_dberrno($linkidentifier = "") { ! global $dbasetype, $peardb; if($peardb) { ! if($linkidentifier != "") { ! return(DB_Error::getCode($linkidentifier)); ! } else { return(DB_Error::getCode()); ! } } elseif($dbasetype == "mysql") { if(function_exists("mysql_errno") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! if($linkidentifier != "") { ! return(mysql_errno($linkidentifier)); ! } else { return(mysql_errno()); ! } } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { *************** *** 134,163 **** die("ODBC support is not enabled in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(odbc_error($connections[$ID]['conn'])); ! /* } else { return(odbc_error()); ! }*/ } exit(0); } ! function ofirst_dberror($ID = 0) { ! global $connections, $dbasetype, $peardb; if($peardb) { ! // if($linkidentifier != "") { ! return(DB_Error::getMessage($connections[$ID]['conn'])); ! /* } else { return(DB_Error::getMessage()); ! }*/ } elseif($dbasetype == "mysql") { if(function_exists("mysql_error") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(mysql_error($connections[$ID]['conn'])); ! /* } else { return(mysql_error()); ! }*/ } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { --- 127,156 ---- die("ODBC support is not enabled in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); } ! if($linkidentifier != "") { ! return(odbc_error($linkidentifier)); ! } else { return(odbc_error()); ! } } exit(0); } ! function ofirst_dberror($linkidentifier = "") { ! global $dbasetype, $peardb; if($peardb) { ! if($linkidentifier != "") { ! return(DB_Error::getMessage($linkidentifier)); ! } else { return(DB_Error::getMessage()); ! } } elseif($dbasetype == "mysql") { if(function_exists("mysql_error") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! if($linkidentifier != "") { ! return(mysql_error($linkidentifier)); ! } else { return(mysql_error()); ! } } elseif ($dbasetype == "mssql") { if(function_exists("mssql_connect") == false) { *************** *** 169,202 **** die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(odbc_errormsg($connections[$ID]['conn'])); ! /* } else { return(odbc_errormsg()); ! }*/ } exit(0); } ! function ofirst_dbquery($string, $ID = 0, $batchsize = "") { ! global $connections, $dbasetype, $peardb, $sqlconnection, $lastquery; ! $lastquery = "ofirst_dbquery(): \$string = \"$string\", \$linkidentifier = \"$linkidentifier\", \$batchsize = \"$batchsize\""; if($peardb) { if($batchsize != "") { ! return($sqlconnection->query($string, $connections[$ID]['conn'], $batchsize)); ! } else/*if($linkidentifier != "")*/ { ! return($sqlconnection->query($string, $connections[$ID]['conn'])); ! }/* else { return($sqlconnection->query($string)); ! }*/ } elseif($dbasetype == "mysql") { if(function_exists("mysql_query") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! // if($linkidentifier != "") { ! return(mysql_query($string, $connections[$ID]['conn'])); ! /* } else { return(mysql_query($string)); ! }*/ } elseif($dbasetype == "mssql") { if(function_exists("mssql_query") == false) { --- 162,195 ---- die("ODBC support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable ODBC support, or choose another database type."); } ! if($linkidentifier != "") { ! return(odbc_errormsg($linkidentifer)); ! } else { return(odbc_errormsg()); ! } } exit(0); } ! function ofirst_dbquery($string, $linkidentifier = "", $batchsize = "") { ! global $dbasetype, $peardb, $sqlconnection, $lastquery; ! $lastquery = "\$string = \"$string\", \$linkidentifier = \"$linkidentifier\", \$batchsize = \"$batchsize\""; if($peardb) { if($batchsize != "") { ! return($sqlconnection->query($string, $linkidentifier, $batchsize)); ! } elseif($linkidentifier != "") { ! return($sqlconnection->query($string, $linkidentifier)); ! } else { return($sqlconnection->query($string)); ! } } elseif($dbasetype == "mysql") { if(function_exists("mysql_query") == false) { die("MySQL support is not available in your version of PHP. To use the openFIRST Web Portal Software, please either enable MySQL support, or choose another database type."); } ! if($linkidentifier != "") { ! return(mysql_query($string, $linkidentifier)); ! } else { return(mysql_query($string)); ! } } elseif($dbasetype == "mssql") { if(function_exists("mssql_query") == false) { *************** *** 204,213 **** } if($batchsize != "") { ! return(mssql_query($string, $connections[$ID]['conn'], $batchsize)); ! } else/*if($linkidentifier != "")*/ { ! return(mssql_query($string, $connections[$ID]['conn'])); ! }/* else { return(mssql_query($string)); ! }*/ } elseif ($dbasetype == "odbc") { if(function_exists("odbc_exec") == false) { --- 197,206 ---- } if($batchsize != "") { ! return(mssql_query($string, $linkidentifier, $batchsize)); ! } elseif($linkidentifier != "") { ! return(mssql_query($string, $linkidentifier)); ! } else { return(mssql_query($string)); ! } } elseif ($dbasetype == "odbc") { if(function_exists("odbc_exec") == false) { *************** *** 215,227 **** } // Note: this may be misleading, the variable names are not reflective of their content in this particular line, as the odbc function uses an order different from the other databases. ! return(odbc_exec($string, $connections[$ID]['conn'])); } exit(0); } ! #FIXME: Make associative arrays ! #FIXME: Use $connections[$ID]['res'] ! function ofirst_dbfetch_object($resource, $rownumber = "", $ID = 0) { ! global $connections, $dbasetype, $peardb; if($peardb) { if($rownumber != "") { --- 208,218 ---- } // Note: this may be misleading, the variable names are not reflective of their content in this particular line, as the odbc function uses an order different from the other databases. ! return(odbc_exec($string, $linkidentifer)); } exit(0); } ! function ofirst_dbfetch_object($resource, $rownumber = "") { ! global $dbasetype, $peardb; if($peardb) { if($rownumber != "") { *************** *** 256,262 **** } - #FIXME: Use $connections[$ID]['res'] function ofirst_dbnum_rows($resource) { ! global $connections, $dbasetype, $peardb; if($peardb) { if($resource != "") { --- 247,252 ---- } function ofirst_dbnum_rows($resource) { ! global $dbasetype, $peardb; if($peardb) { if($resource != "") { *************** *** 288,293 **** } ! function ofirst_dbname_version($ID = 0) { ! global $connections, $dbasetype, $peardb; if($peardb) { return "PEAR DB"; --- 278,283 ---- } ! function ofirst_dbname_version() { ! global $dbasetype, $peardb; if($peardb) { return "PEAR DB"; *************** *** 305,313 **** } ! function ofirst_dbsize($ID = 0) { ! global $connections, $dbasetype, $peardb; if($dbasetype == "mysql") { $dbsize = 0; ! $dq = ofirst_dbquery("SHOW TABLE STATUS FROM " $connections[$ID]['db'], 0); while($d = ofirst_dbfetch_object($dq)) { $dbsize += $d->Data_length + $d->Index_length; --- 295,303 ---- } ! function ofirst_dbsize() { ! global $dbasetype, $peardb; if($dbasetype == "mysql") { $dbsize = 0; ! $dq = ofirst_dbquery("SHOW TABLE STATUS FROM $sqldatabase"); while($d = ofirst_dbfetch_object($dq)) { $dbsize += $d->Data_length + $d->Index_length; *************** *** 315,319 **** return (int) (($dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } elseif($dbasetype == "mssql") { ! $s = ofirst_dbfetch_object(ofirst_dbquery("SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles", 0)); return (int) (( $s->dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } else { --- 305,309 ---- return (int) (($dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } elseif($dbasetype == "mssql") { ! $s = ofirst_dbfetch_object(ofirst_dbquery("SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles")); return (int) (( $s->dbsize + 0.5) / 1024 * 10) / 10 . " KB"; } else { |