/**
  *  Constructor. Set the database table name and necessary field names
  *
  *  @param $table          Name of the tree database table
  *  @param $db             (optional) The YDDatabase instance name or object pointing to the database
  *  @param $idField        (optional) Name of the primary key ID field. Default is id.
  *  @param $parentField    (optional) Name of the parent ID field. Default is parent_id.
  *  @param $sortField      (optional) Name of the field to sort data.
  */
 function YDDatabaseTree2($table, $db = 'default', $idField = 'id', $parentField = 'parent_id', $sortField = 'parent_id ASC, position ASC')
 {
     $this->db = YDDatabase::getNamedInstance($db);
     $this->table = $table;
     $this->fields = array('id' => $idField, 'parent' => $parentField, 'lineage' => 'lineage', 'level' => 'level', 'position' => 'position');
     $this->sortField = $sortField;
 }
 /**
  *  Constructor. Set the database connection
  *
  *  @param $db  (optional) The YDDatabase object pointing to the database. If you use a null value, the default
  *              database instance will be used (using YDDatabase::getNamedInstance()).
  */
 function YDDatabaseMetaData($db = null)
 {
     if (is_null($db)) {
         $this->db = YDDatabase::getNamedInstance();
     } else {
         $this->db = $db;
     }
 }
 /**
  *  Constructor. Set the database table name and necessary field names
  *
  *  @param $db             The YDDatabase instance name or object pointing to the database
  *  @param $table          Name of the tree database table
  *  @param $idField        (optional) Name of the primary key ID field. Default is id.
  *  @param $parentField    (optional) Name of the parent ID field. Default is parent_id.
  *  @param $sortField      (optional) Name of the field to sort data. Default is position, title.
  */
 function YDDatabaseTree($db = 'default', $table, $idField = 'id', $parentField = 'parent_id', $sortField = 'position, title')
 {
     $this->db = YDDatabase::getNamedInstance($db);
     $this->table = $table;
     $this->fields = array('id' => $idField, 'parent' => $parentField, 'sort' => $sortField, 'nleft' => 'nleft', 'nright' => 'nright', 'nlevel' => 'nlevel', 'position' => 'position');
     $this->_use_query_cache = true;
     $this->_query_cache = array();
 }
 function actionDefault()
 {
     // Register the named instances
     YDDatabase::registerInstance('default', 'mysql', 'ydweblog', 'root', '', 'localhost');
     YDDatabase::registerInstance('db_mysql', 'mysql', 'mysql', 'root', '', 'localhost');
     YDDatabase::registerInstance('db_test', 'mysql', 'test', 'root', '', 'localhost');
     // Get the default instance
     $db1 = YDDatabase::getNamedInstance();
     YDDebugUtil::dump($db1, 'default instance, no name given');
     // Get the default instance using it's name
     $db1 = YDDatabase::getNamedInstance('DEFAULT');
     YDDebugUtil::dump($db1, 'default instance, using name');
     // Get the db_mysql instance using it's name
     $db1 = YDDatabase::getNamedInstance('db_mysql');
     YDDebugUtil::dump($db1, 'db_mysql instance');
     // Get the db_bba_v2 instance using it's name
     $db1 = YDDatabase::getNamedInstance('db_test');
     YDDebugUtil::dump($db1, 'db_test instance');
 }
 /**
  *  Class constructor for the YDMysqlDump class.
  *
  *  @param $dbinstance      Database instance name or object.
  */
 function YDMysqlDump($dbinstance = 'default')
 {
     // Initializes YDBase
     $this->YDAddOnModule();
     // Setup the module
     $this->_author = 'Francisco Azevedo';
     $this->_version = '1.3';
     $this->_copyright = '(c) 2005 Francisco Azevedo, francisco@fusemail.com';
     $this->_description = 'This class defines a mysql backup/restore system.';
     // database instance
     $this->dbinstance = YDDatabase::getNamedInstance($dbinstance);
     // predefined filepath for store content (used if we don't want a string)
     $this->filepath = YD_DIR_TEMP . '/backup.sql';
     // defaults
     $this->useComments = false;
     $this->useDrops = false;
     $this->useStructure = false;
     $this->useData = false;
     // custom tables
     $this->tables_to_use = null;
     $this->tables_to_ignore = null;
 }
 /**
  *  The class constructor.
  *
  *  @param $db  The YDDatabase object pointing to the database or the named instance.
  */
 function YDDatabaseQueryDriver($db = null)
 {
     $this->YDBase();
     if (is_null($db)) {
         $this->db = YDDatabase::getNamedInstance();
     } else {
         if (is_string($db)) {
             $this->db = YDDatabase::getNamedInstance($db);
         } else {
             $this->db = $db;
         }
     }
     $this->reset();
     $this->action();
 }
 /**
  *  This function register the database connection.
  *
  *  @param $db  The YDDatabase object pointing to the database or the named instance.
  *
  *  @returns    A reference to the YDDatabase object.
  */
 function &registerDatabase($db = null)
 {
     if (is_null($db)) {
         $this->_db = YDDatabase::getNamedInstance();
     } else {
         if (is_string($db)) {
             $this->_db = YDDatabase::getNamedInstance($db);
         } else {
             $this->_db = $db;
         }
     }
     $this->_query = YDDatabaseQuery::getInstance($this->_db);
     return $this->_db;
 }