我在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;
但没有成功,任何想法如何解决这个问题?
答案 0 :(得分:3)
您必须将字符串插入引号:
$sql = "update catalog_product_entity_varchar
set value = '".$test.$_prodId.$extencion."'
where entity_id = ".$_prodId."
and attribute_id = 86 ";
答案 1 :(得分:1)
$extencion = '.jpg';
$test ='/small/';
$_prodId= 1;
$resource = Mage::getSingleton('core/resource');
$adapter = $resource->getConnection('write');
$bind = array(
'value' => $test.$_prodId.$extencion
);
$where = array(
'entity_id = ?' => $_prodId,
'attribute_id = ?' => 86
);
$adapter->update($resource->getTableName('catalog_product_entity_varchar'), $bind, $where);