Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.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中如何在单引号内传递变量_Php_Sql - Fatal编程技术网

PHP中如何在单引号内传递变量

PHP中如何在单引号内传递变量,php,sql,Php,Sql,我需要从当前日期开始取一个月内发行的图书数量,这就是为什么我需要这样运行: "SELECT * from issued_books where student_id= :s_id and book_name = :b_name and issue_date between :start_date and :end_date" 但在这两者之间,我需要传递'2019-02-27',但我的变量给出了2019-02-27。如何解决此问题?尝试以下方法: $variable = "'2019-02-27

我需要从当前日期开始取一个月内发行的图书数量,这就是为什么我需要这样运行:

"SELECT * from issued_books where student_id= :s_id and book_name = :b_name and issue_date between :start_date and :end_date"
但在这两者之间,我需要传递
'2019-02-27'
,但我的变量给出了
2019-02-27
。如何解决此问题?

尝试以下方法:

$variable = "'2019-02-27'"; // will return '2019-02-27'


应该是这样的。

通过concatationPls给我举个例子@Treybake你尝试过什么吗?对于准备好的语句,你不需要将变量括在引号中。你试过了吗?@Md.Iqbal嗯,你需要向我们展示你的代码,并准确解释它是如何工作的。我建议你先阅读,然后再阅读你的帖子。
$issue_date = "'".$issue_date."'";

"SELECT * from issued_books where student_id= :s_id and book_name = :b_name and {issue_date} between :start_date and :end_date"
$var = "2019-43-43";
"fsdafsdf fsd fsd '{$var}'";
$var = "'2019-43-43'";
"fsdafsdf fsd fsd ".$var;