PHP 클래스 Prado\Data\Common\Mssql\TMssqlCommandBuilder

부터: 3.1
상속: extends Prado\Data\Common\TDbCommandBuilder
파일 보기 프로젝트 열기: pradosoft/prado

공개 메소드들

메소드 설명
applyLimitOffset ( $sql, $limit, $offset ) : string Overrides parent implementation. Alters the sql to apply $limit and $offset.
getLastInsertID ( ) : integer Overrides parent implementation. Uses "SELECT @@Identity".

보호된 메소드들

메소드 설명
findOrdering ( string $sql ) : array Base on simplified syntax http://msdn2.microsoft.com/en-us/library/aa259187(SQL.80).aspx
joinOrdering ( $orders ) : string
reverseDirection ( $orders ) : array
rewriteLimitOffsetSql ( $sql, integer $limit, integer $offset ) : sql Rewrite sql to apply $limit > and $offset > 0 for MSSQL database.

메소드 상세

applyLimitOffset() 공개 메소드

The idea for limit with offset is done by modifying the sql on the fly with numerous assumptions on the structure of the sql string. The modification is done with reference to the notes from http://troels.arvin.dk/db/rdbms/#select-limit-offset SELECT * FROM ( SELECT TOP n * FROM ( SELECT TOP z columns -- (z=n+skip) FROM tablename ORDER BY key ASC ) AS FOO ORDER BY key DESC -- ('FOO' may be anything) ) AS BAR ORDER BY key ASC -- ('BAR' may be anything) Regular expressions are used to alter the SQL query. The resulting SQL query may be malformed for complex queries. The following restrictions apply
  • In particular, commas should NOT be used as part of the ordering expression or identifier. Commas must only be used for separating the ordering clauses.
  • In the ORDER BY clause, the column name should NOT be be qualified with a table name or view name. Alias the column names or use column index.
  • No clauses should follow the ORDER BY clause, e.g. no COMPUTE or FOR clauses.
public applyLimitOffset ( $sql, $limit, $offset ) : string
리턴 string SQL with limit and offset.

findOrdering() 보호된 메소드

Base on simplified syntax http://msdn2.microsoft.com/en-us/library/aa259187(SQL.80).aspx
protected findOrdering ( string $sql ) : array
$sql string
리턴 array ordering expression as key and ordering direction as value

getLastInsertID() 공개 메소드

Overrides parent implementation. Uses "SELECT @@Identity".
public getLastInsertID ( ) : integer
리턴 integer last insert id, null if none is found.

joinOrdering() 보호된 메소드

protected joinOrdering ( $orders ) : string
리턴 string concat the orderings

reverseDirection() 보호된 메소드

protected reverseDirection ( $orders ) : array
리턴 array ordering with reversed direction.

rewriteLimitOffsetSql() 보호된 메소드

See http://troels.arvin.dk/db/rdbms/#select-limit-offset
protected rewriteLimitOffsetSql ( $sql, integer $limit, integer $offset ) : sql
$limit integer > 0
$offset integer > 0
리턴 sql modified sql query applied with limit and offset.