YII框架學(xué)習(xí) 第三天(2) Model view 整合
1.向view 傳入數(shù)據(jù)
$goods = Goods::model();
$goodsInfo = $goods->findAll();
$this->renderPartial('show',array('goodsInfo'=>$goodsInfo));
2.使用sql
$goods->findAllBySql();
3.添加數(shù)據(jù)
$goods_model = new Goods(); //和查詢數(shù)據(jù)不一樣
$goods_model->goods_name = 'APPLE';
$goods_model->goods_price = 5000;
$goods_model->goods_weight =100;
if($goods_model -> save())
{
echo 'success';
}
else
{
ehoc 'fail';
}