開発メモ

開発用のメモです。

EC CUBE SELECT INSERT 文

<?php
// INSERT INTO $table (
//          products_class_id,
//          classcategory_id1,
//          classcategory_name1,
//          classcategory_id2,
//          classcategory_name2
// ) SELECT
//          products_class_id,
//          classcategory_id1,
//          (SELECT name FROM dtb_classcategory WHERE classcategory_id = classcategory_id1) AS classcategory_name1,
//          classcategory_id2,
//          (SELECT name FROM dtb_classcategory WHERE classcategory_id = classcategory_id2) AS classcategory_name2
// FROM dtb_products_class;
$arrVal = array( );
$arrSql = array(
// @formatter:off
    "product_class_id"   =>"product_class_id",
    "classcategory_id1  "=>"classcategory_id1",
    "classcategory_name1"=>"(SELECT name FROM dtb_classcategory WHERE classcategory_id = classcategory_id1) AS classcategory_name1",
    "classcategory_id2"  =>"classcategory_id2",
    "classcategory_name2"=>"(SELECT name FROM dtb_classcategory WHERE classcategory_id = classcategory_id2) AS classcategory_name2",
// @formatter:on
);
$arrSqlVal = array( );
$this->objQuery->insert( $table, $arrVal, $arrSql, $arrSqlVal, " FROM dtb_products_class" );
Twitter: @asahina_alice