2015-10-10 19 views
6

Tôi sử dụng https://github.com/creocoder/yii2-nested-sets phần mở rộng cho Yii2!Bộ lồng nhau cho Yii2 Đối số không hợp lệ được cung cấp cho foreach()

Vì vậy, phiên bản đầu tiên cho Yii1 là tốt nhưng trong phiên bản này tôi có một số vấn đề.

Tất cả được thực hiện theo đúng hướng dẫn!

Khi tạo ra tất cả các mẫu tôi kiếm được lỗi:

enter image description here

enter image description here

Lỗi này xuất hiện ở bất kỳ truy vấn để loại bảng. Nếu toàn bộ tác phẩm hành vi xóa; (

Categories Mẫu:

<?php 

namespace backend\models; 

use creocoder\nestedsets\NestedSetsBehavior; 
use yii\db\ActiveRecord; 

class Categories extends ActiveRecord 
{ 

    public function behaviors() { 
    return [ 
     'tree' => [ 
     'class' => NestedSetsBehavior::className(), 
     'treeAttribute' => 'tree', 
     ], 
    ]; 
    } 

    public function transactions() 
    { 
    return [ 
     self::SCENARIO_DEFAULT => self::OP_ALL, 
    ]; 
    } 

    public static function find() 
    { 
    return new CategoryQuery(get_called_class()); 
    } 
} 

CategoryQuery Mẫu:

<?php 

namespace backend\models; 

use creocoder\nestedsets\NestedSetsQueryBehavior; 
use yii\db\ActiveRecord; 

class CategoryQuery extends ActiveRecord 
{ 
    public function behaviors() { 
    return [ 
     NestedSetsQueryBehavior::className(), 
    ]; 
    } 
} 
+1

hiển thị mô hình loại của bạn và bộ điều khiển – scaisEdge

+0

http://cs628016.vk.me/v628016930/1ea86 /jRzxP35vIkY.jpg – Adobe

+0

http://cs628016.vk.me/v628016930/1ea8d/1eXLUyfYqds.jpg – Adobe

Trả lời

0

ActiveQuery thay ActiveRecord trong lớp CategoryQuery cần

Các vấn đề liên quan