Ejemplo n.º 1
0
 public function actionIndex()
 {
     $query = new CropTypeDo();
     //父节点为根节点
     $query->setParentId(1);
     $query->setIsDelete(0);
     $result = CropType::selectByCropType($query);
     return $this->render('index', ['cropRoot' => $result]);
 }
Ejemplo n.º 2
0
 public static function selectByCropType($cropType)
 {
     $query = CropType::find();
     if ($cropType->cropId != null) {
         $query = $query->where(['CropId' => $cropType->cropId]);
     }
     if ($cropType->cropName != null) {
         $query = $query->where(['CropName' => $cropType->cropName]);
     }
     if ($cropType->parentId != null) {
         $query = $query->where(['ParentId' => $cropType->parentId]);
     }
     if ($cropType->level != null) {
         $query = $query->where(['Level' => $cropType->level]);
     }
     if ($cropType->comment != null) {
         $query = $query->where(['Comment' => $cropType->comment]);
     }
     if ($cropType->isDelete != null) {
         $query = $query->where(['IsDelete' => $cropType->isDelete]);
     }
     return $query->all();
 }