public function selectQuery($model)
{
if ($model->debug) {
echo '<font style="color: blue">db.' . $model->table . '.find(' . json_encode($model->_table[$this->short_name]['conditions']) . ')</font>';
}
$c = $this->_get($model, 'db')->find($model->_table[$this->short_name]['conditions']);
// sort
if ($s = $this->_get($model, 'order')) {
if ($model->debug) {
echo '<font style="color: blue">.sort(' . json_encode($s) . ')</font>';
}
$c->sort($s);
}
$this->_set($model, 'cur', $c);
// skip
if ($l = $this->_get($model, 'limit')) {
list($count, $skip) = $l;
if ($skip) {
if ($model->debug) {
echo '<font style="color: blue">.skip(' . $skip . ')</font>';
}
$c->skip($skip);
}
if ($count) {
if ($model->debug) {
echo '<font style="color: blue">.limit(' . $count . ')</font>';
}
$c->limit($count);
}
}
return $c;
}