/** * @param int $id * @return \Address\Model\City|NULL */ public function get($id) { $dbAdapter = $this->getDbAdapter(); $select = $this->getDbSql()->select(['ct' => self::TABLE_NAME]); $select->where(array('ct.id' => $id)); $query = $this->getDbSql()->buildSqlString($select); $results = $dbAdapter->query($query, $dbAdapter::QUERY_MODE_EXECUTE); if ($results) { $ct = new City(); $ct->exchangeArray((array) $results->current()); return $ct; } return null; }
/** * @author KienNN * @param \Address\Model\City $item */ public function isExisted($item) { if (!$item->getNativeName()) { return null; } $select = $this->getDbSql()->select(['ct' => self::TABLE_NAME]); $select->where(['name' => $item->getNativeName()]); $query = $this->getDbSql()->buildSqlString($select); $results = $this->getDbAdapter()->query($query, Adapter::QUERY_MODE_EXECUTE); if ($results->count()) { $item->exchangeArray((array) $results->current()); return true; } return false; }