/** * Find admin * * @param int $applicationId * @param string $username * @param Admin_Model_Admin $admin * @return boolean */ public function find($applicationId, $username, Admin_Model_Admin $admin) { $select = $this->_dbTable->select(); $select->setIntegrityCheck(false)->from(array('a' => 'admin'), array('a.*'))->joinLeft(array("aa" => "admin_application"), "aa.admin_id = a.id")->where('a.username = ?', $username)->where('aa.application_id = ?', $applicationId); $resultSet = $this->_dbTable->fetchAll($select); if (0 == count($resultSet)) { return false; } //get first row from resultSet $row = $resultSet->current(); $admin->setOptions($row->toArray()); return true; }
public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART) { $Select = parent::select($withFromPart); $Select->assemble(); $Select->setIntegrityCheck(false); return $Select; }
/** * Creating a query using a Model. * * @param Zend_Db_Table_Abstract $model * @param array $relationmap Relation map for joins * * @return $this */ public function __construct(Zend_Db_Table_Abstract $model, array $relationMap = array()) { $this->_model = $model; $this->_relationMap = $relationMap; $info = $model->info(); $select = $model->select(); $map = $info['referenceMap']; $map = array_merge_recursive($map, $this->_relationMap); if (is_array($map) && count($map) > 0) { $select->setIntegrityCheck(false); $columnsToRemove = array(); foreach ($map as $sel) { if (is_array($sel['columns'])) { $columnsToRemove = array_merge($columnsToRemove, $sel['columns']); } else { $columnsToRemove[] = $sel['columns']; } } $columnsMainTable = array_diff($info['cols'], $columnsToRemove); $select->from($info['name'], $columnsMainTable, $info['schema']); $tAlias = array($info['name'] => 1); $this->_setJoins($info['name'], $map, $select, $tAlias); } else { $select->from($info['name'], $info['cols'], $info['schema']); } parent::__construct($select); return $this; }
public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART) { $select = parent::select($withFromPart); if ($this->_multilang_type == 1 && $this->_current_lang) { $select->where('`lang` = ' . $this->_current_lang->id); } return $select; }
/** * Returns a \Zend_Db_Table_Select object to work with * * @return \Zend_Db_Table_Select */ public function getSelect() { if ($this->hasItemsUsed()) { $select = $this->_table->select(\Zend_Db_Table_Abstract::SELECT_WITHOUT_FROM_PART); $select->from($this->_getTableName($this->_table), array()); return $select; } else { return $this->_table->select(\Zend_Db_Table_Abstract::SELECT_WITH_FROM_PART); } }
public function getAttribute($id) { if (isset($this->_attributes[$id])) { return $this->_attributes[$id]; } elseif (is_numeric($id)) { $attribute = $this->_attributeModel->find($id)->current(); } else { $where = $this->_attributeModel->select()->where($this->_attributeFieldName . ' = ?', $id); $attribute = $this->_attributeModel->fetchRow($where); } $this->cacheAttribute($attribute); return $attribute; }
/** * Get data from database table if avalid * @return array */ protected function _parseData() { $data = $this->_data; if ($this->_adapter) { $select = $this->_adapter->select()->where("language=?", $this->_language); $stmt = $select->query(); if ($stmt) { while ($row = $stmt->fetch()) { $data[] = array(self::MESSAGE_ID_KEY => $row[self::MESSAGE_ID_KEY], self::MESSAGE_STRING_KEY => $this->replaceEndLineCharacter($row[self::MESSAGE_STRING_KEY])); } $stmt->closeCursor(); } unset($select, $row, $stmt); } return $data; }
public function loadRow($value, $field = false) { $select = $this->table->select(); //$this->table->getAdapter()->quote($v) // Check if value is an array if (is_array($value)) { foreach ($value as $k => $v) { $select->where("`$k` = ?", $v); } } else { if (!$field) { $field = $this->table->getPrimary(); } $select->where("`$field` = ?", $value); } $this->row = $this->table->fetchRow($select); }
/** * loadDestinationData * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ private function loadDestinationData() { try { $objSelect = $this->objTable->select(); $objSelect->setIntegrityCheck(false); $arrFields = array($this->strDBFLft, $this->strDBFRgt, $this->strDBFDepth); if (!is_null($this->strDBFParent)) { $arrFields[] = $this->strDBFParent; } if (!is_null($this->strDBFRoot)) { $arrFields[] = $this->strDBFRoot; } $objSelect->from($this->objTable->info(Zend_Db_Table_Abstract::NAME), $arrFields); $objSelect->where('id = ?', $this->intDestinationId); $this->objDestinationData = $this->objTable->fetchAll($objSelect); } catch (Exception $exc) { $this->core->logger->err($exc); } }
public function testDbTableSelectDoesNotThrowException() { $adapter = new Zend_Paginator_Adapter_DbSelect($this->_table->select()); $count = $adapter->count(); $this->assertEquals(500, $count); }
public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART) { $select = parent::select($withFromPart); $select->where('removed = ?', false); return $select; }
/** * Index Of Entries * * @return Zend_Paginator */ public function indexOfEntries() { $entrySelect = $this->_entryTable->select(); $paginator = new Zend_Paginator(new Postr_Model_EntryPaginatorAdapter($entrySelect, $this)); return $paginator; }