/** * Creates a COUNT(*) command for a single table. * * @param mixed $table the table schema ({@link TableSchema}) or the table name (string). * @param Criteria $criteria the query criteria * @param string $alias the alias name of the primary table. Defaults to 't'. * * @return Command query command. */ public function createCountCommand($table, $criteria, $alias = 't') { $table_clone = clone $table; if (is_array($table->primaryKey)) { foreach ($table->primaryKey as $pos => $pk) { $table_clone->primaryKey[$pos] = $this->getSchema()->quoteColumnName($pk); } } else { $table_clone->primaryKey = $this->getSchema()->quoteColumnName($table->primaryKey); } return parent::createCountCommand($table_clone, $criteria, $alias); }
/** * Creates a COUNT(*) command for a single table. * Override parent implementation to remove the order clause of criteria if it exists * * @param TableSchema $table the table metadata * @param Criteria $criteria the query criteria * @param string $alias the alias name of the primary table. Defaults to 't'. * * @return Command query command. */ public function createCountCommand($table, $criteria, $alias = 't') { $criteria->order = ''; return parent::createCountCommand($table, $criteria, $alias); }