/** * Fieldname'e göre arama yapıyor. * * @param string $column * @param string $value * @return Soup_Result|array * @todo: Bu method kontrol edilmedi */ public function findBy($fieldName, $params) { $result = Soup_Query::select()->from($this->getTable()->getTableName())->where($fieldName . ' = ?', $params)->execute(); return $result; }
/** * * @param string $order * * @return Soup_Result */ public function orderBy($order) { if ($this->hasParent()) { $foreignKey = $this->getTable()->getForeignKey($this->getParent()->getTable()->getName()); if ($foreignKey['type'] == Soup_Table::RELATION_MANY) { return $this; } else { $where = $this->getParent()->getWhere($this->getTable()->getTableName()); return Soup_Query::select()->from($this->getTable()->getTableName())->where($where[0], $this->getParent()->{$foreignKey['foreign']})->orderBy($order)->execute(); } } else { $freshResult = Soup_Query::select()->from($this->getTable()->getTableName())->orderBy($order); $where = $this->getWhere($this->getTable()->getTableName()); if (!is_null($where)) { $i = 0; foreach ($where as $cond) { if ($i == 0) { $freshResult->where($cond); } else { $freshResult->andWhere($cond); } $i++; } } return $freshResult->execute(); } }
public function fetch() { $query = Soup_Query::select("SQL_CALC_FOUND_ROWS *")->from($this->getTable()->getTableName()); if ($this->_where) { $i = 0; foreach ($this->_where as $where) { if ($i) { $query->andWhere($where['where'], $where['params']); } else { $query->where($where['where'], $where['params']); } $i++; } } if ($this->_limit) { $query->limit($this->_limit); } if ($this->_offset) { $query->offset($this->_offset); } if ($this->_order) { $query->orderBy($this->_order); } $this->_where = array(); $this->_limit = null; $this->_offset = null; $this->_order = null; return $query->execute(); }