Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何解决mysql请求中的此错误_Php_Mysql - Fatal编程技术网

Php 如何解决mysql请求中的此错误

Php 如何解决mysql请求中的此错误,php,mysql,Php,Mysql,我试图找到一个关于这个请求的解决方案。结果总是错的。 插入的唯一数据是优惠券:“测试” 传统知识 内部数据库 coupons_date_start = NULL coupons_date_end = NULL 如果我删除这些元素,请求就会生效 or coupons_date_start <= CURDATE() or coupons_date_start = :coupons_date_start coupons_date_end >= CURDATE or coupons_dat

我试图找到一个关于这个请求的解决方案。结果总是错的。 插入的唯一数据是优惠券:
“测试”

传统知识

内部数据库

coupons_date_start = NULL
coupons_date_end = NULL
如果我删除这些元素,请求就会生效

or coupons_date_start <= CURDATE() or coupons_date_start = :coupons_date_start
coupons_date_end >= CURDATE or coupons_date_end = :coupons_date_start

{ 'coupons_id' => string(4) "test" 'coupons_description' => string(4) "test" 'coupons_discount_amount' => string(14) "5.000000000000" 'coupons_discount_type' => string(5) "fixed" 'coupons_date_start' => NULL 'coupons_date_end' => NULL 'coupons_max_use' => string(1) "0" 'coupons_min_order' => string(6) "0.0000" 'coupons_min_order_type' => string(5) "price" 'coupons_number_available' => string(1) "0" 'coupons_create_account_b2c' => string(1) "0" 'coupons_create_account_b2b' => string(1) "0" 'coupons_twitter' => string(1) "0" }

占位符无法复制。我尝试使用优惠券\u日期\u结束=:优惠券\u日期\u开始1和$QcheckCode->bindValue(“:优惠券\u日期\u开始1”,“000-00-00 00:00:00”)更改的可能重复项;相同的结果优惠券\u日期\u开始和优惠券\u日期\u结束字段的数据类型是什么-null表示字符串不是日期时间数据类型。您能用当前代码更新问题吗?占位符不能重复。我试图用优惠券\u日期\u结束=:优惠券\u日期\u开始1和$QcheckCode->bindValue更改的可能重复(':优惠券日期开始1','000-00-00 00:00:00');相同的结果优惠券日期开始和优惠券日期结束字段的数据类型是什么-null表示字符串不是日期时间数据类型。您能用当前代码更新问题吗?
  $QcheckCode = $OSCOM_Db->prepare('select *
                                    from :table_discount_coupons
                                    where coupons_id = :coupons_id
                                    and (coupons_date_start is null
                                         or coupons_date_start <= CURDATE()
                                         or coupons_date_start = :coupons_date_start
                                         )
                                    and (coupons_date_end >= CURDATE()
                                         or coupons_date_end = :coupons_date_start
                                        )
                                ');

  $QcheckCode->bindValue(':coupons_id', $this->couponCode);
  $QcheckCode->bindValue(':coupons_date_start', '000-00-00 00:00:00');

  $QcheckCode->execute();

  $check_code = $QcheckCode->fetch();

  var_dump($check_code); ==> false
CREATE TABLE `discount_coupons` (
  `coupons_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `coupons_description` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
  `coupons_discount_amount` decimal(15,12) NOT NULL DEFAULT '0.000000000000',
  `coupons_discount_type` enum('fixed','percent','shipping') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'percent',
  `coupons_date_start` datetime DEFAULT NULL,
  `coupons_date_end` datetime DEFAULT NULL,
  `coupons_max_use` int(3) NOT NULL DEFAULT '0',
  `coupons_min_order` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `coupons_min_order_type` enum('price','quantity') COLLATE utf8_unicode_ci DEFAULT 'price',
  `coupons_number_available` int(3) NOT NULL DEFAULT '0',
  `coupons_create_account_b2c` tinyint(1) NOT NULL DEFAULT '0',
  `coupons_create_account_b2b` tinyint(1) NOT NULL DEFAULT '0',
  `coupons_twitter` int(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;