Yii Framework v1.1.10 绫诲弬鑰

CMssqlCommandBuilder

system.db.schema.mssql
缁ф壙 class CMssqlCommandBuilder » CDbCommandBuilder » CComponent
鐗堟湰 $Id: CMssqlCommandBuilder.php 3515 2011-12-28 12:29:24Z mdomba $
婧愮爜 framework/db/schema/mssql/CMssqlCommandBuilder.php
CMssqlCommandBuilder鎻愪緵涓篗SSQL鏁版嵁琛ㄥ垱寤烘煡璇㈣鍙ョ殑鍩烘湰鏂规硶銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
dbConnection CDbConnection database connection. CDbCommandBuilder
schema CDbSchema the schema for this command builder. CDbCommandBuilder

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() CDbCommandBuilder
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
applyCondition() Alters the SQL to apply WHERE clause. CDbCommandBuilder
applyGroup() Alters the SQL to apply GROUP BY. CDbCommandBuilder
applyHaving() Alters the SQL to apply HAVING. CDbCommandBuilder
applyJoin() Alters the SQL to apply JOIN clause. CDbCommandBuilder
applyLimit() This is a port from Prado Framework. CMssqlCommandBuilder
applyOrder() Alters the SQL to apply ORDER BY. CDbCommandBuilder
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
bindValues() Binds parameter values for an SQL command. CDbCommandBuilder
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
createColumnCriteria() Creates a query criteria with the specified column values. CDbCommandBuilder
createCountCommand() 涓轰竴涓〃鍒涘缓COUNT(*)璇彞銆 CMssqlCommandBuilder
createCriteria() Creates a query criteria. CDbCommandBuilder
createDeleteCommand() 鍒涘缓DELETE璇彞銆 CMssqlCommandBuilder
createFindCommand() 涓轰竴涓〃鍒涘缓SELECT璇彞銆 CMssqlCommandBuilder
createInCondition() Generates the expression for selecting rows of specified primary key values. CDbCommandBuilder
createInsertCommand() Creates an INSERT command. CDbCommandBuilder
createPkCondition() Generates the expression for selecting rows of specified primary key values. CDbCommandBuilder
createPkCriteria() Creates a query criteria with the specified primary key. CDbCommandBuilder
createSearchCondition() Generates the expression for searching the specified keywords within a list of columns. CDbCommandBuilder
createSqlCommand() Creates a command based on a given SQL statement. CDbCommandBuilder
createUpdateCommand() 鍒涘缓UPDATE璇彞銆 CMssqlCommandBuilder
createUpdateCounterCommand() 鍒涘缓閫掑鎴栭掑噺鐗瑰畾鍒楃殑UPDATE璇彞銆 CMssqlCommandBuilder
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getDbConnection() 杩斿洖database connection. CDbCommandBuilder
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getLastInsertID() Returns the last insertion ID for the specified table. CDbCommandBuilder
getSchema() 杩斿洖the schema for this command builder. CDbCommandBuilder
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
checkCriteria() 妫鏌ヤ娇鐢╫ffset鎴杔imit鐨勬煡璇㈡潯浠舵槸鍚︽湁order by瀛愬彞銆 CMssqlCommandBuilder
createCompositeInCondition() 鐢熸垚鏍规嵁鎸囧畾绗﹀悎閿奸夋嫨琛岀殑琛ㄨ揪寮忋 CMssqlCommandBuilder
ensureTable() Checks if the parameter is a valid table schema. CDbCommandBuilder
findOrdering() 鍩轰簬绠鍖栬娉曪細http://msdn2.microsoft.com/en-us/library/aa259187(SQL.80).aspx CMssqlCommandBuilder
joinOrdering() CMssqlCommandBuilder
reverseDirection() CMssqlCommandBuilder
rewriteLimitOffsetSql() 涓篗SSQL鏁版嵁搴撻噸鍐橲QL浠ュ簲鐢$limit > 0鍜$offset > 0銆 CMssqlCommandBuilder

鏂规硶璇︾粏

applyLimit() 鏂规硶
public string applyLimit(string $sql, integer $limit, integer $offset)
$sql string SQL鏌ヨ瀛楃涓
$limit integer 鏈澶ц鏁帮紝鑻ヤ负-1鍒欏拷鐣imit銆
$offset integer 琛屽亸绉伙紝鑻ヤ负-1鍒欏拷鐣ffset銆
{return} string 甯︽湁limit鍜宱ffset鐨凷QL銆
婧愮爜锛 framework/db/schema/mssql/CMssqlCommandBuilder.php#179 (鏄剧ず)
public function applyLimit($sql$limit$offset)
{
    
$limit $limit!==null intval($limit) : -1;
    
$offset $offset!==null intval($offset) : -1;
    if (
$limit && $offset <= 0//just limit
        
$sql preg_replace('/^([\s(])*SELECT( DISTINCT)?(?!\s*TOP\s*\()/i',"\\1SELECT\\2 TOP $limit"$sql);
    else if(
$limit && $offset 0)
        
$sql $this->rewriteLimitOffsetSql($sql$limit,$offset);
    return 
$sql;
}

This is a port from Prado Framework.

閲嶅啓鐖剁被鐨勫疄鐜般傛敼鍙楽QL浠ュ簲鐢$limit鍜$offset銆 搴旂敤甯︽湁offset鐨刲imit鏄牴鎹甋QL璇彞缁撴瀯鐨 璁稿鍋囪閫氳繃鍔ㄦ佷慨鏀筍QL瀹炵幇鐨勩 鏍规嵁涓嬮潰鍦板潃鐨勯檮娉ㄥ畬鎴愪慨鏀癸細 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

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.