/**
  * @param int $id
  * @return District|null
  */
 public function get($id)
 {
     $dbAdapter = $this->getDbAdapter();
     $select = $this->getDbSql()->select(array("d" => self::TABLE_NAME));
     $select->where(array('d.id' => $id));
     $query = $this->getDbSql()->buildSqlString($select);
     $results = $dbAdapter->query($query, $dbAdapter::QUERY_MODE_EXECUTE);
     if ($results) {
         $d = new District();
         $d->exchangeArray((array) $results->current());
         return $d;
     }
     return null;
 }
 /**
  * @author KienNN
  * @param \Address\Model\District $item
  */
 public function isExisted($item)
 {
     if (!$item->getName() || !$item->getCityId()) {
         return null;
     }
     $select = $this->getDbSql()->select(array("d" => self::TABLE_NAME));
     $select->where(['name' => $item->getName()]);
     $select->where(['cityId' => $item->getCityId()]);
     $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;
 }