Whenever I try to generate a model using Gii in the Yii framework, it throws:
php warning : count(): Parameter must be an array or an object that implements Countable
It also mentions following file:
app\\protected\\vendor\\yiisoft\\yii\\framework\\gii\\generators\\model\\ModelCode.php(371)
While questions with same title exists, none of them fixed mine.I'm using yii version 1.1.14 and windows 10
你应该将 Yii 升级到 1.1.21 - 这个 bug 大约在 2 年前被修复了。
If you want to fix it without upgrading your existing Yii version, then follow as below. Go to
framework/gii/generators/model/ModelCode.php:371
and fix with
$pk=$table->primaryKey;
$count=is_array($pk) ? count($pk) : 1;
return ($count === 2 // we want 2 columns
Just check the $pk is an array or not and store value in a new variable $count and return it.
使用旧版本的 yii 将 Php 降级到 5.6 可以正常工作。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.