protected function getSqlCommand($criteria)
{
$sql = $criteria->getCondition();
$ordering = $criteria->getOrdersBy();
$limit = $criteria->getLimit();
$offset = $criteria->getOffset();
if (count($ordering) > 0) {
$sql = $this->getBuilder()->applyOrdering($sql, $ordering);
}
if ($limit >= 0 || $offset >= 0) {
$sql = $this->getBuilder()->applyLimitOffset($sql, $limit, $offset);
}
$command = $this->getBuilder()->createCommand($sql);
$this->getBuilder()->bindArrayValues($command, $criteria->getParameters()->toArray());
$this->onCreateCommand($command, $criteria);
return $command;
}