我在 Magento DB 中添加了一个额外的表,称为 kv_mailings。一些额外的产品信息存储在那里,与 Magento 没有任何关系。这就是为什么我添加了一个额外的表。
我使用了这个答案中的 test.php 想法,我的文件如下所示:
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = "SELECT * FROM kv_mailings WHERE sku=hkag";
$row = $connection->fetchRow($sql); //fetchRow($sql), fetchOne($sql),...
Zend_Debug::dump($row);
我的桌子目前看起来像这样:
这就是疯狂的事情开始的地方。当我的查询是SELECT * FROM kv_mailings WHERE sku=SKU
它将选择正确的行并返回:
array(9) {
["id"] => string(1) "1"
["titel"] => string(19) "value"
["sku"] => string(3) "SKU"
["logo"] => string(96) "value"
["background"] => string(84) "value"
["codes_new"] => string(0) ""
["codes_old"] => string(419) "value"
["codes_enc"] => string(6) "CODE11"
["terms"] => string(708) "value"
}
*请注意,我已将实际值更改为value
.
如果我将查询更改为,SELECT * FROM kv_mailings WHERE sku=hkag
我将收到以下错误消息:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'hkag' in 'where clause'' in /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Statement/Pdo.php:228 Stack trace: #0 /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) #1 /var/www/webshop.test.vtnl.net/https/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) #4 /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT * FROM k...', Array) #5 /var/www/webshop.test.vtnl.net/https/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECT * FROM k...', Array) #6 /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Adapt in /var/www/webshop.test.vtnl.net/https/lib/Zend/Db/Statement/Pdo.php on line 234
那是怎么回事?如您所见,表中有一条记录,其中 sku = hkag... 有谁知道发生了什么以及我能做些什么?非常感谢!