php同时添加多条数据——addAll

向week_recipe表中同时添加多条数据:

	$tmp_copy_array = array();
   	foreach ($select_copy_array as $key => $value) {
			$data_copy['dish_name'] 	= $value['dish_name'];
			$data_copy['dish_gram'] 	= $value['dish_gram'];
			$data_copy['material_name'] = $value['material_name'];
			$data_copy['material_gram'] = $value['material_gram'];
			$data_copy['addtime']  		= time();
			array_push($tmp_copy_array, $data_copy);
		}
		$res = M("week_recipe")->addAll($tmp_copy_array);

你可能感兴趣的:(php)