ACC SHELL
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
* @package Nette\Database\Drivers
*/
/**
* Supplemental MS SQL database driver.
*
* @author David Grudl
* @package Nette\Database\Drivers
*/
class NMsSqlDriver extends NObject implements ISupplementalDriver
{
/** @var NConnection */
private $connection;
public function __construct(NConnection $connection, array $options)
{
$this->connection = $connection;
}
/********************* SQL ****************d*g**/
/**
* Delimites identifier for use in a SQL statement.
*/
public function delimite($name)
{
// @see http://msdn.microsoft.com/en-us/library/ms176027.aspx
return '[' . str_replace(array('[', ']'), array('[[', ']]'), $name) . ']';
}
/**
* Formats boolean for use in a SQL statement.
*/
public function formatBool($value)
{
return $value ? '1' : '0';
}
/**
* Formats date-time for use in a SQL statement.
*/
public function formatDateTime(DateTime $value)
{
return $value->format("'Y-m-d H:i:s'");
}
/**
* Encodes string for use in a LIKE statement.
*/
public function formatLike($value, $pos)
{
$value = strtr($value, array("'" => "''", '%' => '[%]', '_' => '[_]', '[' => '[[]'));
return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
}
/**
* Injects LIMIT/OFFSET to the SQL query.
*/
public function applyLimit(& $sql, $limit, $offset)
{
if ($limit >= 0) {
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ') t';
}
if ($offset) {
throw new NotImplementedException('Offset is not implemented.');
}
}
/**
* Normalizes result row.
*/
public function normalizeRow($row, $statement)
{
return $row;
}
/********************* reflection ****************d*g**/
/**
* Returns list of tables.
*/
public function getTables()
{
throw new NotImplementedException;
}
/**
* Returns metadata for all columns in a table.
*/
public function getColumns($table)
{
throw new NotImplementedException;
}
/**
* Returns metadata for all indexes in a table.
*/
public function getIndexes($table)
{
throw new NotImplementedException;
}
/**
* Returns metadata for all foreign keys in a table.
*/
public function getForeignKeys($table)
{
throw new NotImplementedException;
}
/**
* @return bool
*/
public function isSupported($item)
{
return $item === self::SUPPORT_COLUMNS_META;
}
}
ACC SHELL 2018