На этапе изучения Yii решил попробовать написать небольшой магазин и столкнулся с проблемой что $model->save() не выполняется однако ошибок никаких не наблюдаю.
лог:
Loading "log" application component
Loading "request" application component
Loading "viewRenderer" application component
Loading "db" application component
Opening DB connection
Loading "clientScript" application component
Loading "assetManager" application component
Loading "urlManager" application component
Running filter ProductController.filteraccessControl()
Loading "user" application component
Loading "session" application component
Loading "widgetFactory" application component
Category.findAll()
Lookup.findAll()
Loading "coreMessages" application component
Экшн сохранения:
Код: Выделить всё
public function actionCreate()
{
$model=new Product;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Product']))
{
$model->attributes=$_POST['Product'];
if($model->save())
{
echo 'true';
$this->redirect(array('view','id'=>$model->id));
}
else
{
echo 'false';
CVarDumper::dumpAsString($model->getErrors());
}
}
$this->render('create',array(
'model'=>$model,
));
}
Код: Выделить всё
array
(
'category_id' => '2'
'name' => 'Нуга'
'description' => 'арахис'
'price' => '0.00'
'weight' => '0.00'
'width' => '0.00'
'length' => '0.00'
'height' => '0.00'
'count' => '0'
'status' => '1'
)
Код: Выделить всё
return array(
array('name, description', 'required'),
array('name', 'length', 'max'=>150),
array('category_id, status, count', 'numerical', 'integerOnly'=>true),
array('price', 'length', 'max'=>6),
array('weight, width, length, height', 'length', 'max'=>4),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('name, price, status', 'safe', 'on'=>'search'),
);
Код: Выделить всё
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'category' => array(self::BELONGS_TO, 'Category', 'category_id'),
'comments' => array(self::HAS_MANY, 'Comment', 'product_id',
'condition' => 'status = '. Comment::STATUS_APPROVED,
'order' => 'create_time DESC',
),
'commentCount' => array(self::STAT, 'Comment', 'category_id',
'condition' => 'status = '. Comment::STATUS_APPROVED,
),
);
}
Буду признателен если скажите в каком направлении смотреть.
P.S Вопросы типа "А вы в ту бд смотрите?" не задавать.