✏️ 正在编辑: Categoria.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/models/DbTable/Categoria.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Model_DbTable_Categoria extends Core_DbTable { protected $_primary = 'id'; protected $_name = 'tb_categorias'; protected static $_viewName = 'vw_categorias'; protected $_dependentTables = array( 'Model_DbTable_Lancamento', 'Model_DbTable_Categoria', ); protected $_referenceMap = array( 'Categoria' => array( 'columns' => array( 'categoria_pai' ), 'refTableClass' => 'Model_DbTable_Categoria', 'refColumns' => array( 'id' ) ) ); public static function getViewName() { return self::$_viewName; } public function fetchAllParents($order = null) { $order = $order != null ? $order : "nome ASC"; $select = $this->select()->from($this->_name, array('id', 'nome')) ->where("(categoria_pai = 0 OR categoria_pai IS NULL) AND excluido <> 1"); if( $order ){ $select->order($order); } $parents = $this->getAdapter()->fetchAll($select); foreach ( $parents as $key => $categoria ) { $categoria['childrens'] = $this->fetchAllChildren($categoria['id']); $parents[$key] = $categoria; } return $parents; } public function fetchAllChildren($parentId) { $childrens = array( ); $select = $this->select()->from($this->_name, array('id', 'nome')) ->where("categoria_pai = " . $parentId . " AND excluido <> 1"); $select->order("nome"); $dados = $this->getAdapter()->fetchAll($select); foreach ( $dados as $categoria ) { $categoria['childrens'] = $this->fetchAllChildren($categoria['id']); array_push($childrens, $categoria); } return $childrens; } }
💾 保存文件
← 返回文件管理器