✏️ 正在编辑: DbTable.php
路径:
/srv/systems_dir/koruspay/library/Core/DbTable.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Core_DbTable extends Zend_Db_Table_Abstract { protected $_primary = 'id'; public function delete($where) { return $this->update(array( 'deleted' => 1 ), $where); } public function fetchRow($where = null, $order = null, $offset = null) { $cols = $this->_getCols(); if( in_array('deleted', $cols) ){ if( ($where instanceof Zend_Db_Table_Select ) ){ //se tiver um join, espera-se que todos os parãmetros //de busca já foram passados. if( count($where->getPart(Zend_Db_Table_Select::FROM)) <= 1 ){ $strWhere = "{$this->_name}.deleted<>1"; foreach ( $where->getPart(Zend_Db_Table_Select::WHERE) as $w ) { if( strstr($w, "deleted") ){ continue; } if( substr($w, 0, 3) == "AND" ){ $strWhere .= " " . $w; }else{ $strWhere .= " AND " . $w; } } $where->where($strWhere); } } elseif( is_array($where) ){ $strWhere = "{$this->_name}.deleted<>1"; foreach( $where as $key => $w ){ if( is_string(($key)) ){ $strWhere .= " AND " . str_replace("?", "'{$w}'", $key); }else{ $strWhere .= " AND " . $w; } } $where = $strWhere; } elseif($where != null) { $where = $where .= " AND {$this->_name}.deleted<>1"; }else{ $where = "{$this->_name}.deleted<>1"; } } return parent::fetchRow($where, $order, $offset); } public function fetchAll($where = null, $order = null, $count = null, $offset = null) { if( ($where instanceof Zend_Db_Table_Select ) ){ $strWhere = "deleted<>1"; foreach ( $where->getPart(Zend_Db_Table_Select::WHERE) as $w ) { $strWhere .= " AND " . $w; } $where->where($strWhere); } elseif( $where != null ){ $where = $where . " AND deleted<>1"; } else { $where = "deleted<>1"; } return parent::fetchAll($where, $order, $count, $offset); } public function update(array $data, $where) { $dados = $this->fetchRow($where); $result = parent::update($data, $where); // if( $dados != null && $result != null ){ // $log = new Model_DbTable_Log(); // $log->diference($this->_name, $dados->toArray(), $data); // } return $result; } }
💾 保存文件
← 返回文件管理器