Magento用のカスタムインポートスクリプトとプロダクトスクリプトがあります。 スクリプトが長い時間のためにうまく働いた、私はスクリプトの中でいくつかのものを変更しますが、私は変更されていないコマンドは、これは動作を停止したコードであるPHPスクリプトでSQLの更新コマンドが実行され、無視されます
を動作を停止:
require_once("connArray.php");
$dbConfig = GetConn();
$db = Zend_Db::factory('Pdo_Mysql', $dbConfig);
$update = "UPDATE catalog_product_entity_decimal p_dec
SET p_dec.value = $dec_value
WHERE p_dec.entity_id = $entity_id AND p_dec.attribute_id = 64";
echo $update;
echo "<br>";
$result = $db->query($update);
var_dump($result);
echo "<br>";
出力は次のとおりです。
UPDATE catalog_product_entity_decimal p_dec SET p_dec.value = 30.8 WHERE p_dec.entity_id = 2 AND p_dec.attribute_id = 64
object(Zend_Db_Statement_Pdo)#451 (9) { ["_fetchMode:protected"]=> int(2) ["_stmt:protected"]=> object(PDOStatement)#440 (1) { ["queryString"]=> string(124) "UPDATE catalog_product_entity_decimal p_dec SET p_dec.value = 30.8 WHERE p_dec.entity_id = 2 AND p_dec.attribute_id = 64" } ["_adapter:protected"]=> object(Zend_Db_Adapter_Pdo_Mysql)#33 (12) { ["_pdoType:protected"]=> string(5) "mysql" ["_numericDataTypes:protected"]=> array(16) { [0]=> int(0) [1]=> int(1) [2]=> int(2) ["INT"]=> int(0) ["INTEGER"]=> int(0) ["MEDIUMINT"]=> int(0) ["SMALLINT"]=> int(0) ["TINYINT"]=> int(0) ["BIGINT"]=> int(1) ["SERIAL"]=> int(1) ["DEC"]=> int(2) ["DECIMAL"]=> int(2) ["DOUBLE"]=> int(2) ["DOUBLE PRECISION"]=> int(2) ["FIXED"]=> int(2) ["FLOAT"]=> int(2) } ["_defaultStmtClass:protected"]=> string(21) "Zend_Db_Statement_Pdo" ["_config:protected"]=> array(8) { ["host"]=> string(9) "localhost" ["username"]=> string(16) "***" ["password"]=> string(9) "***" ["dbname"]=> string(17) "***" ["driver_options"]=> array(1) { [1002]=> string(14) "SET NAMES UTF8" } ["charset"]=> NULL ["persistent"]=> bool(false) ["options"]=> array(2) { ["caseFolding"]=> int(0) ["autoQuoteIdentifiers"]=> bool(true) } } ["_fetchMode:protected"]=> int(2) ["_profiler:protected"]=> object(Zend_Db_Profiler)#20 (4) { ["_queryProfiles:protected"]=> array(0) { } ["_enabled:protected"]=> bool(false) ["_filterElapsedSecs:protected"]=> NULL ["_filterTypes:protected"]=> NULL } ["_defaultProfilerClass:protected"]=> string(16) "Zend_Db_Profiler" ["_connection:protected"]=> object(PDO)#32 (0) { } ["_caseFolding:protected"]=> int(0) ["_autoQuoteIdentifiers:protected"]=> bool(true) ["_allowSerialization:protected"]=> bool(true) ["_autoReconnectOnUnserialize:protected"]=> bool(false) } ["_attribute:protected"]=> array(0) { } ["_bindColumn:protected"]=> array(0) { } ["_bindParam:protected"]=> array(0) { } ["_sqlSplit:protected"]=> array(1) { [0]=> string(124) "UPDATE catalog_product_entity_decimal p_dec SET p_dec.value = 30.8 WHERE p_dec.entity_id = 2 AND p_dec.attribute_id = 64" } ["_sqlParam:protected"]=> array(1) { [0]=> string(124) "UPDATE catalog_product_entity_decimal p_dec SET p_dec.value = 30.8 WHERE p_dec.entity_id = 2 AND p_dec.attribute_id = 64" } ["_queryId:protected"]=> NULL }
スクリプトが実行された後、私はDBをチェックし、関連する行は変更されませんでした。
出力されたクエリをphpMyAdminにコピーしました。
上記のコードがうまく動作する直前に実行するselectコマンドで、動作するスクリプトに別の更新コマンドがあるため、接続の問題のように見えません。
ありがとうございます。
/////////////////////////////////// UPDATE //////// ///////////////////////////
コードを変更しようとしました〜:
$data = array(
'value' => $dec_value
);
$where[] = "entity_id = " . $entity_id;
$where[] = "attribute_id = 64";
$result = $db->update('catalog_product_entity_decimal', $data, $where);
var_dump($result);
echo "<br>";
しかし、それでも動作しません。 $結果の出力はint(1)です。
私は$ db-> beginTransaction()と$ db-> commit()を追加しようとしましたが(デフォルトではすべてのZend_Dbアダプタクラスが自動コミットモードで動作します)、エラーが発生します: "SQLSTATE [HY000]:一般エラー:1205ロック待ちタイムアウトを超えて、トランザクションを再試行してください"
エラーチェックのために何をしていますか? phpMyAdminのようなインターフェースでクエリを実行しようとしましたか? –
私はphpMyAdminでそれを走らせ、うまくいきました(行が変更されました)。私は何の誤りもありません。 – Shani1351
zendがphp PDOと同じ場合はどのように動作するのかわかりませんが、クエリの代わりに更新を試してください。 http://framework.zend.com/manual/en/zend.db.adapter.htmlでは、$ db-> commit()を試すこともできます。あなたもそれを伝えない限り、コミットしないように見えます。これはクエリを試みますが、まだコミットしません。例23と31を参照してください。 – Matt