Code Search for Developers
 
 
  

database.php from freePBX at Krugle


Show database.php syntax highlighted

<?php

/**
 * @file
 * Functions for the database
 */

/*
 * Database Class
 */
class Database {

  /*
   * Constructor
   */
  function Database() {

    // PEAR must be installed
    require_once('DB.php');
  }

  /*
   * Logs into database and returns database handle
   *

   * @param $engine
   *   database engine
   * @param $dbfile
   *   database file
   * @param $username
   *   username for database
   * @param $password
   *   password for database
   * @param $host
   *   database host
   * @param $name
   *   database name
   * @return $dbh
   *   variable to hold the returned database handle
   */
  function logon($engine,$dbfile,$username,$password,$host,$name) {

    // connect string
    if ($dbfile) {
      // datasource mostly to support sqlite: dbengine://dbfile?mode=xxxx 
      $dsn = $engine . '://' . $dbfile . '?mode=0666';
    } 
    else {
      // datasource in in this style: dbengine://username:password@host/database 
      $datasource = $engine . '://' . $username . ':' . $password . '@' . $host . '/' . $name;
    }

    // options
    $options = array(
      'debug'       => 2,
      'portability' => DB_PORTABILITY_LOWERCASE|DB_PORTABILITY_RTRIM|DB_PORTABILITY_DELETE_COUNT|DB_PORTABILITY_NUMROWS|DB_PORTABILITY_ERRORS|DB_PORTABILITY_NULL_TO_EMPTY,
    );
    
    // attempt connection
    $dbh = DB::connect($datasource,$options); 

    // if connection failed show error
    if(DB::isError($dbh)) {
      $_SESSION['ari_error'] .= $dbh->getMessage() . "<br><br>"; 
      return;
    }
    return $dbh;
  } 
} 


?>



See more files for this project here

freePBX

FreePBX is the most powerful GUI (Web Based) configuration tool for Asterisk. It provides everything that a standard legacy phone system can, plus a huge amount of new features. All documentation and information is avalable from http://www.freepbx.org

Project homepage: http://sourceforge.net/projects/amportal
Programming language(s): PHP,Shell Script,SQL
License: other

  ajax.php
  asi.php
  bootstrap.php
  common.php
  crypt.php
  database.php
  display.php
  lang.php
  login.php
  main.conf.php