download this file: func.dbs.php view text/plain: func.dbs.php file encoding: UTF-8 [goback]
<?php
##
## this file name is 'func.dbs.php'
##
## get dbs object
##
## [author]
##  - Chilbong Kim<san2(at)linuxchannel.net>
##
## [changes]
##  - 2003.07.19 : add dbs_get_count()
##  - 2003.06.11 : new build
##
## [references]
##
## [usage]
##
## [example]
##

## set debug mode an dbms type
##
## arguments :
##    $debug        boolean, debug mode, default false
##    $type        string, DBMS type(mysql(default), pgsql, oracle)
##
## return :
##    $dbs        object, DBMS object
##
function get_dbs($debug=0$type='')
{
  
$type strtolower($type);

  if(!
$type || $type == 'mysql')
  {
    require_once 
'_lib/class.mysql.dbs.php';
    return new 
mysql($debug);
  }

  else if(
$type == 'pgsql')
  {
    require_once 
'_lib/class.pgsql.dbs.php';
    return new 
pgsql($debug);
  }

  return 
FALSE;
}

## get dbs and connect DBMS
##
## arguments :
##    $_dbs        array
##    $_dbs['host']    string, connect to DBMS server
##    $_dbs['user']    string, account of DBMS user
##    $_dbs['pass']    string, password of DBMS user
##    $_dbs['db']        string, select to dbname
##    $debug        boolean, debug mode, default false
##    $type        string, DBMS type(mysql(default), pgsql, oracle)
##
## return :
##    $dbs        object
##
function dbs_connect($_dbs$debug=0$type='')
{
  
$dbs get_dbs($debug,$type);
  
$dbs->connect($_dbs['host'],$_dbs['user'],$_dbs['pass'],$_dbs['db']);

  return 
$dbs;
}

## get count of rows
##
## arguments :
##    $dbs        object, object of DBMS
##    $table        string, target table name
##    $where        string, WHERE ... statement
##
function dbs_get_count($dbs$table$where='')
{
  return 
$dbs->get_count($table,$where);
}

?>