private function _convertSelect($select, $modelKey, $m) { $s = new Kwf_Model_Select(); if ($p = $select->getPart(Kwf_Model_Select::WHERE_ID)) { if (substr($p, 0, strlen($modelKey)) == $modelKey) { $s->whereId(substr($p, strlen($modelKey))); } else { return null; } } if ($p = $select->getPart(Kwf_Model_Select::WHERE_EQUALS)) { foreach ($p as $f => $v) { if ($f == 'id') { if (is_array($v)) { $filterV = array(); foreach ($v as $i) { if (substr($i, 0, strlen($modelKey)) == $modelKey) { $filterV[] = substr($i, strlen($modelKey)); } } if (!$filterV) { return null; } $v = $filterV; } else { if (substr($v, 0, strlen($modelKey)) == $modelKey) { $v = substr($v, strlen($modelKey)); } else { return null; } } } if (in_array($f, $this->_getOwnColumns())) { $f = $this->_mapColumn($m, $f); $s->whereEquals($f, $v); } } } if ($p = $select->getPart(Kwf_Model_Select::WHERE_NOT_EQUALS)) { foreach ($p as $f => $v) { if ($f == 'id') { if (substr($v, 0, strlen($modelKey)) != $modelKey) { continue; } else { $v = substr($v, strlen($modelKey)); } } if (in_array($f, $this->_getOwnColumns())) { $f = $this->_mapColumn($m, $f); $s->whereNotEquals($f, $v); } } } if ($p = $select->getPart(Kwf_Model_Select::WHERE_NULL)) { foreach ($p as $f) { if (in_array($f, $this->_getOwnColumns())) { $f = $this->_mapColumn($m, $f); $s->whereNull($f); } } } if ($p = $select->getPart(Kwf_Model_Select::WHERE_EXPRESSION)) { foreach ($p as $expr) { $e = $this->_convertExpr($expr, $modelKey, $m); if ($e) { $s->where($e); } } } if ($p = $select->getPart(Kwf_Model_Select::IGNORE_DELETED)) { $s->ignoreDeleted($p); } if (isset($this->_mergeSelects[$modelKey])) { $s->merge($this->_mergeSelects[$modelKey]); } return $s; }