protected function toDialectStringSelect($query, Dialect $dialect)
 {
     $fields = array();
     foreach ($this->fields as $var => $val) {
         $fields[] = $dialect->quoteField($var);
     }
     if (!$fields) {
         throw new WrongStateException('what should i insert?');
     }
     if ($this->select->getFieldsCount() != count($fields)) {
         throw new WrongStateException('count of select fields must be equal with count of insert fields');
     }
     $fields = implode(', ', $fields);
     return $query . "({$fields}) (" . $this->select->toDialectString($dialect) . ")";
 }
 public function getCustomRowList(SelectQuery $query, $expires = Cache::DO_NOT_CACHE)
 {
     if ($query->getFieldsCount() !== 1) {
         throw new WrongArgumentException('you should select only one row when using this method');
     }
     if ($expires !== Cache::DO_NOT_CACHE && ($list = $this->getCachedByQuery($query))) {
         if ($list === Cache::NOT_FOUND) {
             throw new CachedObjectNotFoundException();
         }
         return $list;
     } elseif ($list = DBPool::getByDao($this->dao)->queryColumn($query)) {
         if (Cache::DO_NOT_CACHE === $expires) {
             return $list;
         } else {
             return $this->cacheByQuery($query, $list, $expires);
         }
     } else {
         throw new ObjectNotFoundException("empty list" . (defined('__LOCAL_DEBUG__') ? " for such query - " . $query->toDialectString(DBPool::me()->getByDao($this->dao)->getDialect()) : null));
     }
 }