Update of /cvsroot/openfirst/base/includes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14385/includes
Modified Files:
dbase.php
Log Message:
bug fixes, stream lining, removed dependencies on settings, renamed method (more like old name), etc.
Index: dbase.php
===================================================================
RCS file: /cvsroot/openfirst/base/includes/dbase.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** dbase.php 29 Jun 2005 23:47:52 -0000 1.5
--- dbase.php 30 Jun 2005 02:33:43 -0000 1.6
***************
*** 34,38 ****
class DataBase {
! /*private*/ var $type, $connection, $lastquery;
// Wrapper for database selection.
function DataBase($type = 'mysql', $server = '', $username = '', $password = '', $newlink = '', $intclientflags = '') {
--- 34,38 ----
class DataBase {
! /*private*/ var $type, $connection, $lastquery, $db;
// Wrapper for database selection.
function DataBase($type = 'mysql', $server = '', $username = '', $password = '', $newlink = '', $intclientflags = '') {
***************
*** 69,73 ****
}
! /*private*/ function getTypeName() {
$typetext = $this->type;
switch ($this->type) {
--- 69,73 ----
}
! /*public*/ function getTypeName() {
$typetext = $this->type;
switch ($this->type) {
***************
*** 100,103 ****
--- 100,104 ----
function selectDB($databasename) {
+ $this->db = $databasename;
switch ($this->type) {
case dbMYSQL:
***************
*** 192,196 ****
}
! function getObject($resource, $rownumber = false) {
switch ($this->type) {
case dbMYSQL:
--- 193,197 ----
}
! function fetchObject($resource, $rownumber = false) {
switch ($this->type) {
case dbMYSQL:
***************
*** 220,239 ****
function numberOfRows($resource) {
! if($DBaseType == "mysql") {
! if(function_exists("mysql_num_rows") == 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 (!is_resource($resource)) return -1;
! return(mysql_num_rows($resource));
! } elseif($DBaseType == "mssql") {
! if(function_exists("mssql_num_rows") == 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 (!is_resource($resource)) return -1;
! return(mssql_num_rows($resource));
! } elseif($DBaseType == "odbc") {
! if(function_exists("odbc_num_rows") == false) {
! 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($resource != "") {
if (!is_resource($resource)) return -1;
--- 221,239 ----
function numberOfRows($resource) {
! switch ($this->type) {
! case dbMYSQL:
! $this->checkForFunction('mysql_num_rows');
if (!is_resource($resource)) return -1;
! return mysql_num_rows($resource);
! break;
!
! case dbMSSQL:
! $this->checkForFunction('mssql_num_rows');
if (!is_resource($resource)) return -1;
! return mssql_num_rows($resource);
! break;
!
! case dbODBC:
! $this->checkForFunction('odbc_num_rows');
if($resource != "") {
if (!is_resource($resource)) return -1;
***************
*** 242,247 ****
return(odbc_num_rows());
}
}
- exit(0);
}
--- 242,250 ----
return(odbc_num_rows());
}
+ break;
+
+ default:
+ $this->badDBType();
}
}
***************
*** 299,307 ****
function getSize() {
! global $sqlDatabase;
switch ($this->type) {
case dbMYSQL:
$dbsize = 0;
! $dq = $this->query("SHOW TABLE STATUS FROM $sqlDatabase");
while($d = $this->fetchObject($dq)) {
$dbsize += $d->Data_length;
--- 302,310 ----
function getSize() {
! $sqlDatabase = $this->db;
switch ($this->type) {
case dbMYSQL:
$dbsize = 0;
! $dq = $this->query('SHOW TABLE STATUS FROM '.$this->quoteDatabase($sqlDatabase));
while($d = $this->fetchObject($dq)) {
$dbsize += $d->Data_length;
***************
*** 314,318 ****
case dbMSSQL:
! $s = ofirst_dbfetch_object(ofirst_dbquery("SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles"));
return ofFormatSize($s->dbsize);
--- 317,323 ----
case dbMSSQL:
! $res = $this->query('SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles');
! $s = $this->fetchObject($res);
! $this->freeResult($res);
return ofFormatSize($s->dbsize);
|