✏️ 正在编辑: CorretorBancosAtribuidos.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/models/CorretorBancosAtribuidos.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_CorretorBancosAtribuidos { private $_id; private $_corretorId; private $_bancoId; private $_dbtable; public function setDbtable() { return new Model_DbTable_CorretorBancosAtribuidos(); } 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 __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) { $selectBanco = $this->_dbtable->getAdapter()->select()->from(array( 'corretores_bancos' => 'tb_corretores_bancos' ), array( 'id', 'banco_id', 'corretor_id' )) ->joinLeft(array( 'bancos' => 'tb_bancos' ), 'bancos.id = corretores_bancos.banco_id', array( 'banco' => 'bancos.nome', 'teto_producao' )) ->where('corretores_bancos.excluido <> 1') ->order($order); if($where){ $selectBanco->where($where); } return $this->_dbtable->getAdapter()->fetchAll($selectBanco); } /** * Insere ou altera o registro passado por parâmetro * @param Model_CorretorPrazoBanco $corretorPrazoBanco */ public function salvar(Model_CorretorBancosAtribuidos $corretorBancosAtribuidos) { if( $corretorBancosAtribuidos->getId() > 0 ){ $this->_dbtable->update($corretorBancosAtribuidos->_toArray(), 'id = ' . $corretorBancosAtribuidos->getId()); return $corretorBancosAtribuidos->getId(); } else { return $this->_dbtable->insert($corretorBancosAtribuidos->_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; } }
💾 保存文件
← 返回文件管理器