| | |
| | | // | Lorenzo Alberton <l.alberton@quipo.it> | |
| | | // +----------------------------------------------------------------------+ |
| | | // |
| | | // $Id: mssql.php,v 1.109 2008/03/05 12:55:57 afz Exp $ |
| | | // $Id: mssql.php 295587 2010-02-28 17:16:38Z quipo $ |
| | | // |
| | | |
| | | require_once 'MDB2/Driver/Manager/Common.php'; |
| | |
| | | */ |
| | | function createDatabase($name, $options = array()) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function alterDatabase($name, $options = array()) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function dropDatabase($name) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function truncateTable($name) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function vacuum($table = null, $options = array()) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function alterTable($name, $changes, $check) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function _dropConflictingIndices($table, $fields) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function _dropConflictingConstraints($table, $fields) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function _getTableFieldDefaultConstraint($table, $field) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listTables() |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | |
| | | */ |
| | | function listTableFields($table) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | | |
| | | $table = $db->quoteIdentifier($table, true); |
| | | $table = $db->quote($table, 'text'); |
| | | $columns = $db->queryCol("SELECT c.name |
| | | FROM syscolumns c |
| | | LEFT JOIN sysobjects o ON c.id = o.id |
| | | WHERE o.name = '$table'"); |
| | | WHERE o.name = $table"); |
| | | if (PEAR::isError($columns)) { |
| | | return $columns; |
| | | } |
| | |
| | | */ |
| | | function listTableIndexes($table) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listDatabases() |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listUsers() |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listFunctions() |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listTableTriggers($table = null) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | FROM sysobjects o |
| | | WHERE xtype = 'TR' |
| | | AND OBJECTPROPERTY(o.id, 'IsMSShipped') = 0"; |
| | | if (!is_null($table)) { |
| | | if (null !== $table) { |
| | | $query .= " AND object_name(parent_obj) = $table"; |
| | | } |
| | | |
| | |
| | | */ |
| | | function listViews() |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function dropIndex($table, $name) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listTableConstraints($table) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | | $table = $db->quoteIdentifier($table, true); |
| | | $table = $db->quote($table, 'text'); |
| | | |
| | | $query = "SELECT c.constraint_name |
| | | FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS c |
| | | WHERE c.constraint_catalog = DB_NAME() |
| | | AND c.table_name = '$table'"; |
| | | AND c.table_name = $table"; |
| | | $constraints = $db->queryCol($query); |
| | | if (PEAR::isError($constraints)) { |
| | | return $constraints; |
| | |
| | | */ |
| | | function createSequence($seq_name, $start = 1) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function dropSequence($seq_name) |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |
| | |
| | | */ |
| | | function listSequences() |
| | | { |
| | | $db =& $this->getDBInstance(); |
| | | $db = $this->getDBInstance(); |
| | | if (PEAR::isError($db)) { |
| | | return $db; |
| | | } |