✏️ 正在编辑: Empresa.php
路径:
/srv/systems_dir/yuppiecred/application/models/DbTable/Empresa.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_Empresa extends Core_DbTable { protected $_primary = 'id'; protected $_name = 'tb_empresas'; protected static $_viewName = 'vw_empresas'; protected $_dependentTables = array( 'Model_DbTable_Corretor', 'Model_DbTable_Cliente', ); public static function getViewName() { return self::$_viewName; } public function fetchAll($where = null, $order = null, $count = null, $offset = null) { if( ($where instanceof Zend_Db_Table_Select ) ){ $strWhere = "excluido<>1 AND tipo = 'EMPRESA'"; foreach ( $where->getPart(Zend_Db_Table_Select::WHERE) as $w ) { $strWhere .= " AND " . $w; } $where->where($strWhere); } elseif( $where != null ){ $where = $where . " AND excluido<>1 AND tipo = 'EMPRESA'"; } else { $where = "excluido<>1 AND tipo = 'EMPRESA'"; } return parent::fetchAll($where, $order, $count, $offset); } public function fetchColumns($key, array $fields, $where = null, $order = null) { if( is_array($where) ){ $where[] = "excluido <> 1 AND tipo = 'EMPRESA'"; }elseif($where != null){ $where .= " AND tipo = 'EMPRESA'"; }else{ $where = "tipo = 'EMPRESA'"; } return parent::fetchColumns($key, $fields, $where, $order); } /** * @return array */ public function findPrimeiraEmpresaAtiva(): array { $select = $this->getAdapter() ->select() ->from($this->_name) ->where('excluido <> ?', 1) ->order('id ASC') ->limit(1) ; return $this->getAdapter()->fetchRow($select); } /** * @param int $promotora * @return array|null */ public function findByCodigoPromotora(int $promotora): ?array { $select = $this->getAdapter() ->select() ->from(['e' => $this->_name]) ->join(['ftp' => 'tb_empresas_ftps'], 'ftp.empresa_id = e.id', ['codigo_promotora']) ->where('ftp.codigo_promotora = ?', $promotora) ->where('e.excluido <> ?', 1) ->where('ftp.excluido <> ?', 1) ; $empresa = $this->getAdapter()->fetchRow($select); return !empty($empresa) ? $empresa : null; } }
💾 保存文件
← 返回文件管理器