framework/db/schema/CDbCommandBuilder.php
public function createPkCriteria($table,$pk,$condition='',$params=array(),$prefix=null)
	{
		$this->ensureTable($table);
		$criteria=$this->createCriteria($condition,$params);
		if($criteria->alias!='')
			$prefix=$this->_schema->quoteTableName($criteria->alias).'.';
		if(!is_array($pk)) // single key
			$pk=array($pk);
		if(is_array($table->primaryKey) && !isset($pk[0]) && $pk!==array()) // single composite key
			$pk=array($pk);
		$condition=$this->createInCondition($table,$table->primaryKey,$pk,$prefix);
		if($criteria->condition!='')
			$criteria->condition=$condition.' AND ('.$criteria->condition.')';
		else
			$criteria->condition=$condition;

		return $criteria;
	}
public function createPkCriteria($table,$pk,$condition='',$params=array(),$prefix=null)
	{
		$this->ensureTable($table);
		$criteria=$this->createCriteria($condition,$params);
		if($criteria->alias!='')
			$prefix=$this->_schema->quoteTableName($criteria->alias).'.';
		if(!is_array($pk)) // single key
			$pk=array($pk);
		if(is_array($table->primaryKey) && !isset($pk[0]) && $pk!==array()) // single composite key
			$pk=array($pk);
		$condition=$this->createInCondition($table,$table->primaryKey,$pk,$prefix);
		if($criteria->condition!='')
			$criteria->condition=$condition.' AND ('.$criteria->condition.')';
		else
			$criteria->condition=$condition;

		return $criteria;
	}
public function createPkCriteria ( $ table , $ pk , $ condition = '' , $ params = array ( ) , $ prefix = null ) { $ this -> ensureTable ( $ table ) ; $ criteria = $ this -> createCriteria ( $ condition , $ params ) ; if ( $ criteria -> alias != '' ) $ prefix = $ this -> _schema -> quoteTableName ( $ criteria -> alias ) . '.' ; if ( ! is_array ( $ pk ) ) // single key $ pk = array ( $ pk ) ; if ( is_array ( $ table -> primaryKey ) && ! isset ( $ pk [ 0 ] ) && $ pk !== array ( ) ) // single composite key $ pk = array ( $ pk ) ; $ condition = $ this -> createInCondition ( $ table , $ table -> primaryKey , $ pk , $ prefix ) ; if ( $ criteria -> condition != '' ) $ criteria -> condition = $ condition . ' AND (' . $ criteria -> condition . ')' ; else $ criteria -> condition = $ condition ; return $ criteria ; }
Creates a query criteria with the specified primary key.
@param mixed $table the table schema ({@link CDbTableSchema}) or the table name (string).
@param mixed $pk primary key value(s). Use array for multiple primary keys. For composite key, each key value must be an array (column name=>column value).
@param mixed $condition query condition or criteria.
If a string, it is treated as query condition;
If an array, it is treated as the initial values for constructing a {@link CDbCriteria};
Otherwise, it should be an instance of {@link CDbCriteria}.
@param array $params parameters to be bound to an SQL statement.
This is only used when the second parameter is a string (query condition).
In other cases, please use {@link CDbCriteria::params} to set parameters.
@param string $prefix column prefix (ended with dot). If null, it will be the table name
@return CDbCriteria the created query criteria
Creates a query criteria with the specified primary key .