模型Product文件 vendor\fancyecommerce\fecshop\models\mongodb\Product.php中的,为什么把属性$_customProductAttrs 定为成static,不用定义成static 不也是更好吗?
namespace fecshop\models\mongodb;
use yii\mongodb\ActiveRecord;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Product extends ActiveRecord
{
public static $_customProductAttrs;
const STATUS_ENABLE = 1;
const STATUS_DISABLE = 2;
const IS_IN_STOCK = 1;
const OUT_STOCK = 2;
/**
* mongodb collection 的名字,相当于mysql的table name
*/
public static function collectionName()
{
return 'product_flat';
}
/**
* get custom product attrs.
*/
public static function addCustomProductAttrs($attrs)
{
self::$_customProductAttrs = $attrs;
}