php - Mysql更新串联变量

标签 php mysql magento

我在 Magento 的 PHP 中有以下代码,它试图将特定文件中的连接值插入到一个表中

    $extencion = '.jpg';
    $test ='/small/';
    $_prodId= 1;

   $conn  = Mage::getSingleton('core/resource')->getConnection('core_write');

$sql = "update catalog_product_entity_varchar
        set value = ".$test.$_prodId.$extencion."
        where entity_id = ".$_prodId."
        and attribute_id  = 86 ";

$result = $conn->query($sql);

我尝试在更新前连接值

$concatenate = $test.$_prodId.$extencion;

但是没有成功,知道如何解决这个问题吗?

最佳答案

你必须在引号中插入字符串:

$sql = "update catalog_product_entity_varchar
    set value = '".$test.$_prodId.$extencion."'
    where entity_id = ".$_prodId."
    and attribute_id  = 86 ";

关于php - Mysql更新串联变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27639016/

相关文章:

php - #34;而不是“在网站上显示

magento - 新产品不会发生货币转换

php - 如何覆盖 Magento 模型中的表名和前缀?

php - 如何使用 jQuery 将磅转换为千克?

PHP 转换变音符号,例如 "ue"到 "ü"

php - 警告 : mysql_query() expects parameter 1 to be string,

php - htaccess 文件 : Force going to https instead of http except for specific pages

没有页面刷新的php/ajax弹出编辑

magento - 如何更改列数 Magento

mysql - 无法在 Netbean 中加载身份验证插件 'caching_sha2_password'