cvs: pear /DBA DBA_Relational.php

From: Date: Fri, 19 Jul 2002 06:50:07 +0000
Subject: cvs: pear /DBA DBA_Relational.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5192@lists.php.net to get a copy of this message
busterb Fri Jul 19 02:50:07 2002 EDT Modified files: /pear/DBA DBA_Relational.php Log: added two system tables; _table for holding table information, _sequence for holding sequences. with _table, we can now keep track of the drivers used in a table, making it possible for open to select the correct driver automatically Index: pear/DBA/DBA_Relational.php diff -u pear/DBA/DBA_Relational.php:1.40 pear/DBA/DBA_Relational.php:1.41 --- pear/DBA/DBA_Relational.php:1.40 Thu Jul 18 15:10:38 2002 +++ pear/DBA/DBA_Relational.php Fri Jul 19 02:50:07 2002 @@ -18,7 +18,7 @@ // | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA| // +----------------------------------------------------------------------+ // -// $Id: DBA_Relational.php,v 1.40 2002/07/18 19:10:38 busterb Exp $ +// $Id: DBA_Relational.php,v 1.41 2002/07/19 06:50:07 busterb Exp $ require_once 'PEAR.php'; require_once 'DB/DBA/DBA_Table.php'; @@ -79,9 +79,20 @@ $this->_driver = $driver; - if (!$this->tableExists('_tables')) { - $this->createTable('_tables', - array('name'=>array(DBA_TYPE=>DBA_VARCHAR, DBA_SIZE=>30))); + // create the _table table. this keeps track of the tables to be used + // in DBA_Relational as well as which driver to use for each. + if (!$this->tableExists('_table')) { + $this->createTable('_table', + array('name'=>array(DBA_TYPE=>DBA_VARCHAR,DBA_PRIMARYKEY=>true), + 'driver'=>array(DBA_TYPE=>DBA_VARCHAR))); + } + + // create the _sequence table. this keeps track of named sequences + if (!$this->tableExists('_sequence')) { + $this->createTable('_sequence', + array('name'=>array(DBA_TYPE=>DBA_VARCHAR,DBA_PRIMARYKEY=>true), + 'value'=>array(DBA_TYPE=>DBA_INTEGER), + 'increment'=>array(DBA_TYPE=>DBA_INTEGER))); } } // }}} @@ -176,12 +187,16 @@ * @access public * @param string $tableName name of the table to create * @param array $schema field schema for the table + * @param string $driver driver to use for this table * @return object PEAR_Error on failure */ - function createTable($tableName, $schema) + function createTable($tableName, $schema, $driver=null) { - return DBA_Table::create($this->_home.$tableName, $schema, - $this->_driver); + if (is_null($driver)) { + $driver = $this->_driver; + } + $this->insert('_table', array($tableName, $driver)); + return DBA_Table::create($this->_home.$tableName, $schema, $driver); } // }}}

« previous php.pear.cvs (#5192) next »