Source for file Mssql.php
Documentation is available at Mssql.php
* $Id: Mssql.php 1178 2007-03-18 20:00:45Z 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>.
* Doctrine_Connection_Mssql
* @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)
* @version $Revision: 1178 $
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @var string $driverName the name of this connection driver
* @param Doctrine_Manager $manager
* @param PDO $pdo database handle
public function __construct(Doctrine_Manager $manager, $adapter)
// initialize all driver options
'sequences' =>
'emulated',
'summary_functions' =>
true,
'current_id' =>
'emulated',
'limit_queries' =>
'emulated',
'auto_increment' =>
true,
'result_introspection' =>
true,
'prepared_statements' =>
'emulated',
* Quote a string so it can be safely used as a table / column name
* Quoting style depends on which database driver is being used.
* @param string $identifier identifier name to be quoted
* @param bool $checkOption check the 'quote_identifier' option
* @return string quoted identifier string
return '[' .
str_replace(']', ']]', $identifier) .
']';
* Adds an adapter-specific LIMIT clause to the SELECT statement.
* [ borrowed from Zend Framework ]
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
$orderby =
stristr($query, 'ORDER BY');
if ($orderby !==
false) {
$sort =
(stripos($orderby, 'desc') !==
false) ?
'desc' :
'asc';
$query =
preg_replace('/^SELECT\s/i', 'SELECT TOP ' .
($count+
$offset) .
' ', $query);
$query =
'SELECT * FROM (SELECT TOP ' .
$count .
' * FROM (' .
$query .
') AS inner_tbl';
if ($orderby !==
false) {
$query .=
' ORDER BY ' .
$order .
' ';
$query .=
(stripos($sort, 'asc') !==
false) ?
'DESC' :
'ASC';
$query .=
') AS outer_tbl';
if ($orderby !==
false) {
$query .=
' ORDER BY ' .
$order .
' ' .
$sort;
* return version information about the server
* @param bool $native determines if the raw version string should be returned
* @return mixed array/string with version information or MDB2 error object
$query =
'SELECT @@VERSION';
if (preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $serverInfo, $tmp)) {
* Checks if there's a sequence that exists.
* @param string $seq_name The sequence name to verify.
* @return boolean The value if the table exists or not
$query =
'SELECT * FROM ' .
$seqName;
if ($e->getPortableCode() ==
Doctrine::ERR_NOSUCHTABLE) {