mirror of
https://github.com/atlanticbiomedical/portal-legacy.git
synced 2025-07-02 01:47:28 -04:00
initial commit
This commit is contained in:
232
lib/symfony/vendor/creole/metadata/ColumnInfo.php
vendored
Executable file
232
lib/symfony/vendor/creole/metadata/ColumnInfo.php
vendored
Executable file
@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* $Id: ColumnInfo.php,v 1.13 2005/02/25 15:47:02 pachanga Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a Column.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.13 $
|
||||
* @package creole.metadata
|
||||
*/
|
||||
class ColumnInfo {
|
||||
|
||||
// FIXME
|
||||
// - Currently all member attributes are public. This should be fixed
|
||||
// when PHP's magic __sleep() and __wakeup() functions & serialization support
|
||||
// handles protected/private members. (if ever)
|
||||
|
||||
/** Column name */
|
||||
public $name;
|
||||
|
||||
/** Column Creole type. */
|
||||
public $type;
|
||||
|
||||
/** Column native type */
|
||||
public $nativeType;
|
||||
|
||||
/** Column length */
|
||||
public $size;
|
||||
|
||||
/** Column presision */
|
||||
public $precision;
|
||||
|
||||
/** Column scale (number of digits after decimal ) */
|
||||
public $scale;
|
||||
|
||||
/** Is nullable? */
|
||||
public $isNullable;
|
||||
|
||||
/** Default value */
|
||||
public $defaultValue;
|
||||
|
||||
/** Is autoincrement? */
|
||||
public $isAutoIncrement;
|
||||
|
||||
/** Table */
|
||||
public $table;
|
||||
|
||||
/**
|
||||
* Additional and optional vendor specific information.
|
||||
* @var vendorSpecificInfo
|
||||
*/
|
||||
protected $vendorSpecificInfo = array();
|
||||
|
||||
/**
|
||||
* Construct a new ColumnInfo object.
|
||||
*
|
||||
* @param TableInfo $table The table that owns this column.
|
||||
* @param string $name Column name.
|
||||
* @param int $type Creole type.
|
||||
* @param string $nativeType Native type name.
|
||||
* @param int $size Column length.
|
||||
* @param int $scale Column scale (number of digits after decimal).
|
||||
* @param boolean $is_nullable Whether col is nullable.
|
||||
* @param mixed $default Default value.
|
||||
* @param boolean $is_auto_increment Whether col is of autoIncrement type.
|
||||
*/
|
||||
function __construct(TableInfo
|
||||
$table,
|
||||
$name,
|
||||
$type = null,
|
||||
$nativeType = null,
|
||||
$size = null,
|
||||
$precision=null,
|
||||
$scale = null,
|
||||
$is_nullable = null,
|
||||
$default = null,
|
||||
$is_auto_increment = null,
|
||||
$vendorInfo = array())
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->nativeType = $nativeType;
|
||||
$this->size = $size;
|
||||
$this->precision = $precision;
|
||||
$this->scale = $scale;
|
||||
$this->isNullable = $is_nullable;
|
||||
$this->defaultValue = $default;
|
||||
$this->isAutoIncrement = $is_auto_increment;
|
||||
$this->vendorSpecificInfo = $vendorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* This "magic" method is invoked upon serialize().
|
||||
* Because the Info class hierarchy is recursive, we must handle
|
||||
* the serialization and unserialization of this object.
|
||||
* @return array The class variables that should be serialized (all must be public!).
|
||||
*/
|
||||
function __sleep()
|
||||
{
|
||||
return array('name', 'type', 'nativeType', 'size', 'precision', 'isNullable', 'defaultValue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column type.
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the native type name.
|
||||
* @return string
|
||||
*/
|
||||
public function getNativeType()
|
||||
{
|
||||
return $this->nativeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column size.
|
||||
* @return int
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column precision.
|
||||
* @return int
|
||||
*/
|
||||
public function getPrecision()
|
||||
{
|
||||
return $this->precision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get column scale.
|
||||
* Scale refers to number of digits after the decimal. Sometimes this is referred
|
||||
* to as precision, but precision is the total number of digits (i.e. length).
|
||||
* @return int
|
||||
*/
|
||||
public function getScale()
|
||||
{
|
||||
return $this->scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value.
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultValue()
|
||||
{
|
||||
return $this->defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is column nullable?
|
||||
* @return boolean
|
||||
*/
|
||||
public function isNullable()
|
||||
{
|
||||
return $this->isNullable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is column of autoincrement type?
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAutoIncrement()
|
||||
{
|
||||
return $this->isAutoIncrement === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor specific optional information for this column.
|
||||
* @return array vendorSpecificInfo[]
|
||||
*/
|
||||
public function getVendorSpecificInfo()
|
||||
{
|
||||
return $this->vendorSpecificInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent table.
|
||||
* @return TableInfo
|
||||
*/
|
||||
public function getTable()
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
}
|
207
lib/symfony/vendor/creole/metadata/DatabaseInfo.php
vendored
Executable file
207
lib/symfony/vendor/creole/metadata/DatabaseInfo.php
vendored
Executable file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* $Id: DatabaseInfo.php,v 1.15 2005/11/08 04:24:50 hlellelid Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* "Info" metadata class for a database.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.15 $
|
||||
* @package creole.metadata
|
||||
*/
|
||||
abstract class DatabaseInfo {
|
||||
|
||||
protected $tables = array();
|
||||
|
||||
protected $sequences = array();
|
||||
|
||||
/** have tables been loaded */
|
||||
protected $tablesLoaded = false;
|
||||
|
||||
/** have sequences been loaded */
|
||||
protected $seqsLoaded = false;
|
||||
|
||||
/** additional vendor specific information */
|
||||
private $vendorSpecificInfo = array();
|
||||
|
||||
/**
|
||||
* The database Connection.
|
||||
* @var Connection
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/** Database name. */
|
||||
protected $dbname;
|
||||
|
||||
/**
|
||||
* Database link
|
||||
* @var resource
|
||||
*/
|
||||
protected $dblink;
|
||||
|
||||
/**
|
||||
* @param Connection $dbh
|
||||
*/
|
||||
public function __construct(Connection $conn, $vendorInfo = array())
|
||||
{
|
||||
$this->conn = $conn;
|
||||
$this->dblink = $conn->getResource();
|
||||
$dsn = $conn->getDSN();
|
||||
$this->dbname = $dsn['database'];
|
||||
$this->vendorSpecificInfo = $vendorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of database.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->dbname;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is invoked upon serialize().
|
||||
* Because the Info class hierarchy is recursive, we must handle
|
||||
* the serialization and unserialization of this object.
|
||||
* @return array The class variables that should be serialized (all must be public!).
|
||||
*/
|
||||
function __sleep()
|
||||
{
|
||||
return array('tables','sequences','conn');
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is invoked upon unserialize().
|
||||
* This method re-hydrates the object and restores the recursive hierarchy.
|
||||
*/
|
||||
function __wakeup()
|
||||
{
|
||||
// Re-init vars from serialized connection
|
||||
$this->dbname = $conn->database;
|
||||
$this->dblink = $conn->connection;
|
||||
|
||||
// restore chaining
|
||||
foreach($this->tables as $tbl) {
|
||||
$tbl->database = $this;
|
||||
$tbl->dbname = $this->dbname;
|
||||
$tbl->dblink = $this->dblink;
|
||||
$tbl->schema = $this->schema;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Connection being used.
|
||||
* @return Connection
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TableInfo object for specified table name.
|
||||
* @param string $name The name of the table to retrieve.
|
||||
* @return TableInfo
|
||||
* @throws SQLException - if table does not exist in this db.
|
||||
*/
|
||||
public function getTable($name)
|
||||
{
|
||||
if(!$this->tablesLoaded) $this->initTables();
|
||||
if (!isset($this->tables[strtoupper($name)])) {
|
||||
throw new SQLException("Database `".$this->dbname."` has no table `".$name."`");
|
||||
}
|
||||
return $this->tables[ strtoupper($name) ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether database contains specified table.
|
||||
* @param string $name The table name.
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasTable($name)
|
||||
{
|
||||
if(!$this->tablesLoaded) $this->initTables();
|
||||
return isset($this->tables[strtoupper($name)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets array of TableInfo objects.
|
||||
* @return array TableInfo[]
|
||||
*/
|
||||
public function getTables()
|
||||
{
|
||||
if(!$this->tablesLoaded) $this->initTables();
|
||||
return array_values($this->tables); //re-key [numerically]
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a table to this db.
|
||||
* Table name is case-insensitive.
|
||||
* @param TableInfo $table
|
||||
*/
|
||||
public function addTable(TableInfo $table)
|
||||
{
|
||||
$this->tables[strtoupper($table->getName())] = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws SQLException
|
||||
*/
|
||||
abstract protected function initTables();
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws SQLException
|
||||
*/
|
||||
abstract protected function initSequences();
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @throws SQLException
|
||||
*/
|
||||
public function isSequence($key)
|
||||
{
|
||||
if(!$this->seqsLoaded) $this->initSequences();
|
||||
return isset($this->sequences[ strtoupper($key) ]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets array of ? objects.
|
||||
* @return array ?[]
|
||||
*/
|
||||
public function getSequences()
|
||||
{
|
||||
if(!$this->seqsLoaded) $this->initSequences();
|
||||
return array_values($this->sequences); //re-key [numerically]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor specific optional information for this primary key.
|
||||
* @return array vendorSpecificInfo[]
|
||||
*/
|
||||
public function getVendorSpecificInfo()
|
||||
{
|
||||
return $this->vendorSpecificInfo;
|
||||
}
|
||||
}
|
||||
|
103
lib/symfony/vendor/creole/metadata/ForeignKeyInfo.php
vendored
Executable file
103
lib/symfony/vendor/creole/metadata/ForeignKeyInfo.php
vendored
Executable file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* $Id: ForeignKeyInfo.php,v 1.9 2005/08/02 14:42:36 sethr Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a foreign key.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.9 $
|
||||
* @package creole.metadata
|
||||
*/
|
||||
class ForeignKeyInfo {
|
||||
|
||||
private $name;
|
||||
private $references = array();
|
||||
|
||||
/**
|
||||
* Additional and optional vendor specific information.
|
||||
* @var vendorSpecificInfo
|
||||
*/
|
||||
protected $vendorSpecificInfo = array();
|
||||
|
||||
|
||||
const NONE = ""; // No "ON [ DELETE | UPDATE]" behaviour specified.
|
||||
const NOACTION = "NO ACTION";
|
||||
const CASCADE = "CASCADE";
|
||||
const RESTRICT = "RESTRICT";
|
||||
const SETDEFAULT = "SET DEFAULT";
|
||||
const SETNULL = "SET NULL";
|
||||
|
||||
/**
|
||||
* @param string $name The name of the foreign key.
|
||||
*/
|
||||
function __construct($name, $vendorInfo = array())
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->vendorSpecificInfo = $vendorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get foreign key name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a foreign-local mapping.
|
||||
* @param ColumnInfo $local
|
||||
* @param ColumnInfo $foreign
|
||||
*/
|
||||
public function addReference(ColumnInfo $local, ColumnInfo $foreign, $onDelete = self::NONE, $onUpdate = self::NONE)
|
||||
{
|
||||
$this->references[] = array($local, $foreign, $onDelete, $onUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the local-foreign column mapping.
|
||||
* @return array array( [0] => array([0] => local ColumnInfo object, [1] => foreign ColumnInfo object, [2] => onDelete, [3] => onUpdate) )
|
||||
*/
|
||||
public function getReferences()
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor specific optional information for this primary key.
|
||||
* @return array vendorSpecificInfo[]
|
||||
*/
|
||||
public function getVendorSpecificInfo()
|
||||
{
|
||||
return $this->vendorSpecificInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
}
|
84
lib/symfony/vendor/creole/metadata/IndexInfo.php
vendored
Executable file
84
lib/symfony/vendor/creole/metadata/IndexInfo.php
vendored
Executable file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: IndexInfo.php,v 1.7 2005/02/25 15:47:02 pachanga Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents an index.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.7 $
|
||||
* @package creole.metadata
|
||||
*/
|
||||
class IndexInfo {
|
||||
|
||||
/** name of the index */
|
||||
private $name;
|
||||
|
||||
/** columns in this index */
|
||||
private $columns = array();
|
||||
|
||||
/** uniqueness flag */
|
||||
private $isUnique = false;
|
||||
|
||||
/** additional vendor specific information */
|
||||
private $vendorSpecificInfo = array();
|
||||
|
||||
function __construct($name, $isUnique = false, $vendorInfo = array())
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->isUnique = $isUnique;
|
||||
$this->vendorSpecificInfo = $vendorInfo;
|
||||
}
|
||||
|
||||
public function isUnique()
|
||||
{
|
||||
return $this->isUnique;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor specific optional information for this index.
|
||||
* @return array vendorSpecificInfo[]
|
||||
*/
|
||||
public function getVendorSpecificInfo()
|
||||
{
|
||||
return $this->vendorSpecificInfo;
|
||||
}
|
||||
|
||||
public function addColumn($column)
|
||||
{
|
||||
$this->columns[] = $column;
|
||||
}
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
}
|
91
lib/symfony/vendor/creole/metadata/PrimaryKeyInfo.php
vendored
Executable file
91
lib/symfony/vendor/creole/metadata/PrimaryKeyInfo.php
vendored
Executable file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/*
|
||||
* $Id: PrimaryKeyInfo.php,v 1.6 2005/02/25 15:47:02 pachanga Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a PrimaryKey
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.6 $
|
||||
* @package creole.metadata
|
||||
*/
|
||||
class PrimaryKeyInfo {
|
||||
|
||||
/** name of the primary key */
|
||||
private $name;
|
||||
|
||||
/** columns in the primary key */
|
||||
private $columns = array();
|
||||
|
||||
/** additional vendor specific information */
|
||||
private $vendorSpecificInfo = array();
|
||||
|
||||
/**
|
||||
* @param string $name The name of the foreign key.
|
||||
*/
|
||||
function __construct($name, $vendorInfo = array())
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->vendorSpecificInfo = $vendorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get foreign key name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
* @return void
|
||||
*/
|
||||
public function addColumn($column)
|
||||
{
|
||||
$this->columns[] = $column;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array Column[]
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor specific optional information for this primary key.
|
||||
* @return array vendorSpecificInfo[]
|
||||
*/
|
||||
public function getVendorSpecificInfo()
|
||||
{
|
||||
return $this->vendorSpecificInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
305
lib/symfony/vendor/creole/metadata/TableInfo.php
vendored
Executable file
305
lib/symfony/vendor/creole/metadata/TableInfo.php
vendored
Executable file
@ -0,0 +1,305 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* $Id: TableInfo.php,v 1.16 2005/10/17 19:05:10 dlawson_mi Exp $
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information please see
|
||||
* <http://creole.phpdb.org>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a table.
|
||||
*
|
||||
* @author Hans Lellelid <hans@xmpl.org>
|
||||
* @version $Revision: 1.16 $
|
||||
* @package creole.metadata
|
||||
*/
|
||||
abstract class TableInfo {
|
||||
|
||||
protected $name;
|
||||
protected $columns = array();
|
||||
protected $foreignKeys = array();
|
||||
protected $indexes = array();
|
||||
protected $primaryKey;
|
||||
|
||||
protected $pkLoaded = false;
|
||||
protected $fksLoaded = false;
|
||||
protected $indexesLoaded = false;
|
||||
protected $colsLoaded = false;
|
||||
protected $vendorLoaded = false;
|
||||
|
||||
/**
|
||||
* Additional and optional vendor specific information.
|
||||
* @var vendorSpecificInfo
|
||||
*/
|
||||
protected $vendorSpecificInfo = array();
|
||||
|
||||
/**
|
||||
* Database Connection.
|
||||
* @var Connection
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* The parent DatabaseInfo object.
|
||||
* @var DatabaseInfo
|
||||
*/
|
||||
protected $database;
|
||||
|
||||
/** Shortcut to db resource link id (needed by drivers for queries). */
|
||||
protected $dblink;
|
||||
|
||||
/** Shortcut to db name (needed by many drivers for queries). */
|
||||
protected $dbname;
|
||||
|
||||
/**
|
||||
* @param string $table The table name.
|
||||
* @param string $database The database name.
|
||||
* @param resource $dblink The db connection resource.
|
||||
*/
|
||||
function __construct(DatabaseInfo $database, $name) {
|
||||
$this->database = $database;
|
||||
$this->name = $name;
|
||||
$this->conn = $database->getConnection(); // shortcut because all drivers need this for the queries
|
||||
$this->dblink = $this->conn->getResource();
|
||||
$this->dbname = $database->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* This "magic" method is invoked upon serialize().
|
||||
* Because the Info class hierarchy is recursive, we must handle
|
||||
* the serialization and unserialization of this object.
|
||||
* @return array The class variables that should be serialized (all must be public!).
|
||||
*/
|
||||
function __sleep()
|
||||
{
|
||||
return array('name', 'columns', 'foreignKeys', 'indexes', 'primaryKey');
|
||||
}
|
||||
|
||||
/**
|
||||
* This "magic" method is invoked upon unserialize().
|
||||
* This method re-hydrates the object and restores the recursive hierarchy.
|
||||
*/
|
||||
function __wakeup()
|
||||
{
|
||||
// restore chaining
|
||||
foreach($this->columns as $col) {
|
||||
$col->table = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the columns.
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initColumns();
|
||||
|
||||
/**
|
||||
* Loads the primary key information for this table.
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initPrimaryKey();
|
||||
|
||||
/**
|
||||
* Loads the foreign keys for this table.
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initForeignKeys();
|
||||
|
||||
/**
|
||||
* Loads the indexes information for this table.
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function initIndexes();
|
||||
|
||||
/**
|
||||
* Loads the vendor specific information for this table.
|
||||
* @return void
|
||||
*/
|
||||
//it must be asbtract and be implemented in every vendor specific driver,
|
||||
//however since it's an experimental stuff it has an empty body in order
|
||||
//not to break BC
|
||||
/*abstract*/ protected function initVendorSpecificInfo(){}
|
||||
|
||||
/**
|
||||
* Get parimary key in this table.
|
||||
* @throws Exception - if foreign keys are unsupported by DB.
|
||||
* @return array ForeignKeyInfo[]
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
if(!$this->pkLoaded) $this->initPrimaryKey();
|
||||
return $this->primaryKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ColumnInfo object for specified column.
|
||||
* @param string $name The column name.
|
||||
* @return ColumnInfo
|
||||
* @throws SQLException - if column does not exist for this table.
|
||||
*/
|
||||
public function getColumn($name)
|
||||
{
|
||||
if(!$this->colsLoaded) $this->initColumns();
|
||||
if (!isset($this->columns[$name])) {
|
||||
throw new SQLException("Table `".$this->name."` has no column `".$name."`");
|
||||
}
|
||||
return $this->columns[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether table contains specified column.
|
||||
* @param string $name The column name.
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasColumn($name)
|
||||
{
|
||||
if(!$this->colsLoaded) $this->initColumns();
|
||||
return isset($this->columns[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of columns for this table.
|
||||
* @return array ColumnInfo[]
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
if(!$this->colsLoaded) $this->initColumns();
|
||||
return array_values($this->columns); // re-key numerically
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specified fk for this table.
|
||||
* @param string $name The foreign key name to retrieve.
|
||||
* @return ForeignKeyInfo
|
||||
* @throws SQLException - if fkey does not exist for this table.
|
||||
*/
|
||||
public function getForeignKey($name)
|
||||
{
|
||||
if(!$this->fksLoaded) $this->initForeignKeys();
|
||||
if (!isset($this->foreignKeys[$name])) {
|
||||
throw new SQLException("Table `".$this->name."` has no foreign key `".$name."`");
|
||||
}
|
||||
return $this->foreignKeys[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all foreign keys.
|
||||
* @return array ForeignKeyInfo[]
|
||||
*/
|
||||
public function getForeignKeys()
|
||||
{
|
||||
if(!$this->fksLoaded) $this->initForeignKeys();
|
||||
return array_values($this->foreignKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the IndexInfo object for a specified index.
|
||||
* @param string $name The index name to retrieve.
|
||||
* @return IndexInfo
|
||||
* @throws SQLException - if index does not exist for this table.
|
||||
*/
|
||||
public function getIndex($name)
|
||||
{
|
||||
if(!$this->indexesLoaded) $this->initIndexes();
|
||||
if (!isset($this->indexes[$name])) {
|
||||
throw new SQLException("Table `".$this->name."` has no index `".$name."`");
|
||||
}
|
||||
return $this->indexes[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of IndexInfo objects for this table.
|
||||
* @return array IndexInfo[]
|
||||
*/
|
||||
public function getIndexes()
|
||||
{
|
||||
if(!$this->indexesLoaded) $this->initIndexes();
|
||||
return array_values($this->indexes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getIndexes() method.
|
||||
* @return array
|
||||
*/
|
||||
public function getIndices()
|
||||
{
|
||||
return $this->getIndexes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table name.
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/** Have foreign keys been loaded? */
|
||||
public function foreignKeysLoaded()
|
||||
{
|
||||
return $this->fksLoaded;
|
||||
}
|
||||
|
||||
/** Has primary key info been loaded? */
|
||||
public function primaryKeyLoaded()
|
||||
{
|
||||
return $this->pkLoaded;
|
||||
}
|
||||
|
||||
/** Have columns been loaded? */
|
||||
public function columnsLoaded()
|
||||
{
|
||||
return $this->colsLoaded;
|
||||
}
|
||||
|
||||
/** Has index information been loaded? */
|
||||
public function indexesLoaded()
|
||||
{
|
||||
return $this->indexesLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor specific optional information for this table.
|
||||
* @return array vendorSpecificInfo[]
|
||||
*/
|
||||
public function getVendorSpecificInfo()
|
||||
{
|
||||
if(!$this->vendorLoaded) $this->initVendorSpecificInfo();
|
||||
return $this->vendorSpecificInfo;
|
||||
}
|
||||
|
||||
/** Adds a column to this table. */
|
||||
public function addColumn(ColumnInfo $column)
|
||||
{
|
||||
$this->columns[$column->getName()] = $column;
|
||||
}
|
||||
|
||||
/** Get the parent DatabaseInfo object. */
|
||||
public function getDatabase()
|
||||
{
|
||||
return $this->database;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user