[英]Update joomla database with variable
I have tried working with Joomla Framework and I got my update working, but how do I update with a variable. 我已经尝试过使用Joomla Framework,并且可以正常进行更新,但是如何使用变量进行更新。 Fx:
外汇:
$test = 'Hello';
$fields = array(
$db->quoteName('test_column') . ' = ' . $db->quote('$test')
);
How do I write the $test
variable in this line? 如何在此行中编写
$test
变量?
In php, you want to single quote ( '
) strings when you want to output them as you see them, and double quotes ( "
) when you want the string to be parsed for variables. All you need to do is change the quotes around $test
, or more simply remove them as they aren't needed here: 在php中,当您希望看到的字符串输出时,您想使用单引号(
'
),而对于变量进行解析时,则要使用双引号( "
)。所有您需要做的就是更改引号$test
,或更简单地删除它们,因为这里不需要它们:
$test = 'Hello';
$fields = array(
$db->quoteName('test_column') . ' = ' . $db->quote($test)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.