本文整理汇总了PHP中think\Model::addAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::addAll方法的具体用法?PHP Model::addAll怎么用?PHP Model::addAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类think\Model
的用法示例。
在下文中一共展示了Model::addAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAll
public function addAll($rows)
{
$result = parent::addAll($rows);
//删除购物车中的数据
/*if($result!==false){
D('ShoppingCar')->where(array('member_id'=>UID))->delete();
}*/
return $result;
}
示例2: add
public function add($requestData)
{
//>>1.取出用户选择的商品组合
$goods_attribute_idses = $requestData['goods_attribute_ids'];
//保存之前先删除
$this->where(array('goods_id' => $requestData['goods_id']))->delete();
$rows = array();
foreach ($goods_attribute_idses as $goods_attribute_ids) {
$rows[] = array('goods_id' => $requestData['goods_id'], 'goods_attribute_ids' => $goods_attribute_ids, 'price' => $requestData['price'][$goods_attribute_ids], 'stock' => $requestData['stock'][$goods_attribute_ids]);
}
if (!empty($rows)) {
$result = parent::addAll($rows);
if ($result === false) {
$this->error = '保存产品出错!';
return false;
}
}
}
示例3: testAdd
public function testAdd()
{
$config = $this->getConfig();
$time = time();
$user_model = new Model('test.user', $config);
$data = ['username' => 'test', 'password' => md5('123456'), 'status' => 1, 'create_time' => $time];
$user_id = $user_model->data($data)->add();
$data = ['username' => 'test2', 'password' => md5('000000'), 'status' => 1, 'create_time' => $time];
$user_model->add($data, true);
$data = [['user_id' => $user_id, 'consignee' => '张三', 'area_info' => '广东深圳', 'city_id' => '42', 'area_id' => '111', 'address' => 'xx路xx号', 'mobile' => '1380000000000', 'isdefault' => '1'], ['user_id' => $user_id, 'consignee' => '李四', 'area_info' => '广东深圳', 'city_id' => '42', 'area_id' => '111', 'address' => 'xx路xx号', 'mobile' => '13999999999', 'isdefault' => '0']];
$address_model = new Model('user_address', $config);
$address_id = $address_model->addAll($data, [], true);
$data = [['user_id' => $user_id, 'sn' => '10001', 'amount' => '200', 'freight_fee' => '10', 'address_id' => $address_id - 1, 'status' => '1', 'create_time' => $time], ['user_id' => $user_id, 'sn' => '10002', 'amount' => '350.80', 'freight_fee' => '10', 'address_id' => $address_id, 'status' => '0', 'create_time' => $time]];
$address_model = new Model('order', $config);
$address_model->addAll($data);
$data = ['user_id' => $user_id, 'role_id' => 1];
$config['db_name'] = 'test';
$config['attr_case'] = 2;
$model = new Model('', $config);
$model->table($config['prefix'] . 'role_user')->data($data)->add();
}