Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Query Builder для Yii
public function buildQuery($query)
{
$sql=isset($query['distinct']) && $query['distinct'] ? 'SELECT DISTINCT' : 'SELECT';
$sql.=' '.(isset($query['select']) ? $query['select'] : '*');
if(isset($query['from']))
$sql.="\nFROM ".$query['from'];
else
throw new CDbException(Yii::t('yii','The DB query must contain the "from" portion.'));
if(isset($query['where']))
$sql.="\nWHERE ".$query['where'];
if(isset($query['join']))
$sql.="\n".(is_array($query['join']) ? implode("\n",$query['join']) : $query['join']);
if(isset($query['group']))
$sql.="\nGROUP BY ".$query['group'];
if(isset($query['having']))
$sql.="\nHAVING ".$query['having'];
if(isset($query['order']))
$sql.="\nORDER BY ".$query['order'];
$limit=isset($query['limit']) ? (int)$query['limit'] : -1;
$offset=isset($query['offset']) ? (int)$query['offset'] : -1;
if($limit>=0 && $offset>=0)
$sql=$this->_connection->getCommandBuilder()->applyLimit($sql,$limit,$offset);
if(isset($query['union']))
$sql.="\nUNION (\n".(is_array($query['union']) ? implode("\n) UNION (\n",$query['union']) : $query['union']) . ')';
return $sql;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.