Пример #1
0
 /**
  * @param ReadQueryBuilder $builder
  *
  * @return array|null
  */
 public function readOne(ReadQueryBuilder $builder)
 {
     return $this->getMysql()->fetchRow($builder->renderQuery(), $builder->getConditions());
 }
Пример #2
0
 /**
  * @param ReadQueryBuilder $builder
  *
  * @return string
  */
 private function buildReadQuery(ReadQueryBuilder $builder)
 {
     $query = "SELECT {$builder->getColumns()} FROM {$builder->getTableName()}";
     if ($builder->getJoins()) {
         $query .= " " . join("\n", $builder->getJoins());
     }
     if ($builder->getConds()) {
         $query .= " WHERE {$this->buildCondsQuery($builder->getConds(), $builder->getCondsQuery())}";
     }
     if ($builder->getSorting()) {
         $sorting = join(', ', $builder->getSorting());
         $query .= " ORDER BY {$sorting}";
     }
     return $query;
 }