php - mysql插入返回多行

标签 php mysql

<分区>

我有一个插入查询但有错误:子查询返回多于 1 行

INSERT INTO `room_rating`  (
    `date`,
    `room_typeid`,
    `final_price`,
    `commission`,
    `room_available`,
    `rating_status`,
    `hourate_percent_off`,
    `num_days_refund`,
    `none_refund`,
    `cancel_charge_fullcharge`,
    `num_night_charge`,
    `amendment_date`,
    `name_charge`,
    `infant_minage`,
    `infant_maxage`,
    `infant_sh_parent`,
    `infant_extrabed`,
    `infant_isfreebreak`,
    `infant_breakfast_price`,
    `child_minage`,
    `child_maxage`,
    `child_sh_parent`,
    `child_extrabed`,
    `child_isfreebreak`,
    `child_breakfast_price`
)
VALUES
    (
        '2015-11-09',
        '3',
        '2.50',
        '5',
        '6',
        '9',
        '50',
        '',
        0,
        0,
        '',
        0,
        0,
        '0',
        '5',
        0,
        0,
        1,
        0,
        '6',
        '11',
        0,
        0,
        1,
        0
    )

最佳答案

$arrdate=$this->GetDays($start_date,$to_date);
        for ($i=0; $i < count($arrdate); $i++) { 
            $this->db->where('date',$arrdate[$i])->where('room_typeid',$room_typeid)->where("rating_status <>",'ON')->delete('room_rating');//"DELETE room_rating WHERE date='".$arrdate[$i]."' AND room_typeid='$room_typeid'");

        for ($j=0; $j < count($is_hourrate); $j++) { 
            // echo $is_hourrate[$j];
            $data=array(
                        // 'rating_id'=>$rating_name,
                        'date'=>$arrdate[$i],
                        'room_typeid'=>$room_typeid,
                        'final_price'=>$this->input->post('last_price_'.$is_hourrate[$j]),
                        'commission'=>$commission,
                        'room_available'=>$room_available,

                        'rating_status'=>$is_hourrate[$j],
                        'hourate_percent_off'=>$this->input->post('price_'.$is_hourrate[$j]),

                        'num_days_refund'=>$this->input->post('hcancel_duedate'),
                        'none_refund'=>$none_refund,
                        'cancel_charge_fullcharge'=>$full_chage,
                        'num_night_charge'=>$this->input->post('hcancel_charge'),
                        'amendment_date'=>$this->input->post('hamend_date'),

                        'name_charge'=>$this->input->post('hname_charge'),
                        'infant_minage'=>$this->input->post('hrate_infant_minage'),
                        'infant_maxage'=>$this->input->post('hrate_infant_maxage'),
                        'infant_sh_parent'=>$rate_infant_sh_parent,

                        'infant_extrabed'=>$rate_infant_extrabed,
                        'infant_isfreebreak'=>$rate_infant_isfreebreak,
                        'infant_breakfast_price'=>$this->input->post('hrate_infant_breakfast_price'),
                        'child_minage'=>$this->input->post('hrate_child_minage'),

                        'child_maxage'=>$this->input->post('hrate_child_maxage'),
                        'child_sh_parent'=>$rate_child_sh_parent,
                        'child_extrabed'=>$rate_child_extrabed,
                        'child_isfreebreak'=>$rate_child_isfreebreak,

                        'child_breakfast_price'=>$this->input->post('hrate_child_breakfast_price')
                        ); 
            $this->db->insert('room_rating',$data);
        }
    }

View Screenshot

关于php - mysql插入返回多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33949763/

相关文章:

java - RDBMSLoginModule : ClassCastException com. ibm.ws.jdbc.DataSourceService 到 javax.sql.DataSource

PHP和MySQL动态查询只返回没有where子句的结果

php - Zend Framework 2 设置全局模块变量

php - 无法在 Laravel 模型中使用 PHP Trait

javascript - 我可以使用 JavaScript 请求网页,然后将其按原样发送到服务器以进行进一步分析吗?

php - 将 MySQL 结果转换为链接,然后使用 POST 重定向到下一页

带 session 的 PHP 登录系统

php - 准备好的语句不适用于 SELECT 语句

python - Python 中的 MD5 哈希函数更改数据

mysql - Rails 2 hook 在读取/写入 MySQL DB 之前修改数据