Source for file Mssql.php
Documentation is available at Mssql.php
* $Id: Mssql.php 1889 2007-06-28 12:11:55Z zYne $
* 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, see
* <http://www.phpdoctrine.com>.
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Frank M. Kromann <frank@kromann.info> (PEAR MDB2 Mssql driver)
* @author David Coallier <davidc@php.net> (PEAR MDB2 Mssql driver)
* @version $Revision: 1889 $
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* lists all database sequences
* @param string|null$database
$query =
"SELECT name FROM sysobjects WHERE xtype = 'U'";
$tableNames =
$this->conn->fetchColumn($query);
return array_map(array($this->conn->formatter, 'fixSequenceName'), $tableNames);
* lists table constraints
* @param string $table database table name
$sql =
'EXEC sp_columns @table_name = ' .
$this->conn->quoteIdentifier($table, true);
$result =
$this->conn->fetchAssoc($sql);
foreach ($result as $key =>
$val) {
if (strstr($val['type_name'], ' ')) {
list
($type, $identity) =
explode(' ', $val['type_name']);
$type =
$val['type_name'];
if ($type ==
'varchar') {
$type .=
'(' .
$val['length'] .
')';
$decl =
$this->conn->dataDict->getPortableDeclaration($val);
'name' =>
$val['column_name'],
'type' =>
$decl['type'][0],
'alltypes' =>
$decl['type'],
'length' =>
$decl['length'],
'fixed' =>
$decl['fixed'],
'unsigned' =>
$decl['unsigned'],
'notnull' => (bool)
($val['is_nullable'] ===
'NO'),
'default' =>
$val['column_def'],
'primary' =>
(strtolower($identity) ==
'identity'),
$columns[$val['column_name']] =
$description;
* lists table constraints
* @param string $table database table name
* @param string|null$database
$sql =
"SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
return $this->conn->fetchColumn($sql);
$query =
"SELECT name FROM sysobjects WHERE xtype = 'TR'";
$result =
$this->conn->fetchColumn($query);
* @param string $table database table name
$table =
$this->conn->quote($table, 'text');
$query =
"SELECT name FROM sysobjects WHERE xtype = 'TR' AND object_name(parent_obj) = " .
$table;
$result =
$this->conn->fetchColumn($query);
* @param string $table database table name
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE) {
if ($this->conn->options['field_case'] ==
CASE_LOWER) {
$table =
$this->conn->quote($table, 'text');
$query =
'EXEC sp_statistics @table_name = ' .
$table;
$indexes =
$this->conn->fetchColumn($query, $keyName);
$query =
'EXEC sp_pkeys @table_name = ' .
$table;
$pkAll =
$this->conn->fetchColumn($query, $pkName);
foreach ($indexes as $index) {
if (!in_array($index, $pkAll) &&
$index !=
null) {
$result[] =
$this->conn->formatter->fixIndexName($index);
* @param string|null$database
$query =
"SELECT name FROM sysobjects WHERE xtype = 'V'";
return $this->conn->fetchColumn($query);