✏️ 正在编辑: CorretorPrazoBanco.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/CorretorPrazoBanco.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CorretorPrazoBanco { private $_id; private $_corretorId; private $_bancoId; private $_prazo; private $_dbtable; public function setDbtable() { return new Model_DbTable_CorretorPrazoBanco(); } public function getId() { return $this->_id; } public function setId($id) { $this->_id = $id; } public function getCorretorId() { return $this->_corretorId; } public function setCorretorId($corretorId) { $this->_corretorId = $corretorId; } public function getBancoId() { return $this->_bancoId; } public function setBancoId($bancoId) { $this->_bancoId = $bancoId; } public function getPrazo() { return $this->_prazo; } public function setPrazo($prazo) { $this->_prazo = $prazo; } public function __construct($options = null) { if( is_array($options) ){ $this->setOptions($options); } $this->_dbtable = $this->setDbtable(); } public function setOptions(array $options) { $methods = get_class_methods($this); foreach ( $options as $key => $value ) { $explode = explode('_', $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'set' . ucfirst($key); if( in_array($method, $methods) ){ $this->$method($value); } } return $this; } public function _toArray() { $info = $this->_dbtable->info(); $methods = get_class_methods($this); $data = array(); foreach ( $info['cols'] as $key ) { $col = $key; $explode = explode('_', $key); $methodName = ''; foreach ( $explode as $v ) { $methodName .= ucfirst($v); } $key = $methodName != '' ? $methodName : $key; $method = 'get' . ucfirst($key); if( in_array($method, $methods) ){ $data[$col] = $this->$method(); } } return $data; } /** * Retorna um fetchRow do item passado por parâmetro * @param int $id * @return Zend_Db_Table_Row_Abstract | null */ public function exibir($id) { return $this->_dbtable->fetchRow("id = {$id}"); } /** * Retorna uma lista * @param string $where * @param string $order * @param int $count * @param int $offset * @return array */ public function listar($where = null, $order = "banco ASC", $count = null, $offset = null) { $selectPrazo = $this->_dbtable->getAdapter()->select()->from(array( 'corretor_prazo' => 'tb_corretores_prazos' ), array( 'id', 'banco_id', 'corretor_id', 'prazo' )) ->joinLeft(array( 'bancos' => 'tb_bancos' ), 'bancos.id = corretor_prazo.banco_id', array( 'banco' => 'bancos.nome', 'teto_producao' )) ->where('corretor_prazo.excluido <> 1') ->order($order); if($where){ $selectPrazo->where($where); } return $this->_dbtable->getAdapter()->fetchAll($selectPrazo); } /** * Insere ou altera o registro passado por parâmetro * @param Model_CorretorPrazoBanco $corretorPrazoBanco */ public function salvar(Model_CorretorPrazoBanco $corretorPrazoBanco) { if( $corretorPrazoBanco->getId() > 0 ){ $this->_dbtable->update($corretorPrazoBanco->_toArray(), 'id = ' . $corretorPrazoBanco->getId()); return $corretorPrazoBanco->getId(); } else { return $this->_dbtable->insert($corretorPrazoBanco->_toArray()); } } /** * Exclui o registro passado por parâmetro * @param int $id * @return int The number of rows deleted */ public function excluir($id) { if( $id > 0 ){ return $this->_dbtable->delete("id = {$id}"); } return null; } }
💾 保存文件
← 返回文件管理器