예제 #1
0
 /**
  * @param array $criteria
  * @param null $limit
  * @param array $orderBy
  * @param array $groupBy
  * @return array
  */
 public function findBy(array $criteria = array(), $limit = null, $orderBy = array(), $groupBy = null)
 {
     $query = $this->fpdo->from($this->table);
     if (!empty($criteria)) {
         $query->where($criteria);
     }
     if (!empty($orderBy)) {
         $query->orderBy($orderBy);
     }
     if ($limit) {
         $query->limit($limit);
     }
     if ($groupBy) {
         $query->groupBy($groupBy);
     }
     $results = $query->fetchAll();
     return $this->bindCollection($results);
 }
예제 #2
0
 protected function quote($value)
 {
     if (!isset($value)) {
         return "NULL";
     }
     if (is_array($value)) {
         // (a, b) IN ((1, 2), (3, 4))
         return "(" . implode(", ", array_map(array($this, 'quote'), $value)) . ")";
     }
     $value = $this->formatValue($value);
     if (is_float($value)) {
         return sprintf("%F", $value);
         // otherwise depends on setlocale()
     }
     if ($value === false) {
         return "0";
     }
     if (is_int($value) || $value instanceof FluentLiteral) {
         // number or SQL code - for example "NOW()"
         return (string) $value;
     }
     return $this->fpdo->getPdo()->quote($value);
 }