« 知っていた事だけどなかなか実行できなかった(台所編) | メイン | 市民活動情報誌 コラボレーションVol6が発行されました(゜∀゜) »

ZenCart1.2.xで1054 - Unknown column 'p.products_id' in 'on clause'のエラー

MySQL5.0xにアップグレードしたらこのエラーでカテゴリーをクリックしても表示されない現象が出た。

いろいろ記事は載っていたが肝心のソース部分がなかなか見つからなかった。。。orz

こちらのサイト様にソースが記載されていたので覚え書きの意味でこちらに記しておきます。

当方の環境はPHP4です。

なお、ZenCart1.3.xではこの現象は回避されているそうです。

 

ZenCart/includes/modules/meta_tags.php 176行目付近

from ((" . TABLE_PRODUCTS . " p), " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd on mtpd.products_id = p.products_id and mtpd.language_id = '" . (int)$_SESSION['languages_id'] . "'

ZenCart/includes/blocks/blk_advanced_search_result.php 85行目付近

$from_str = "from (((" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd), " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd on mtpd.products_id= p.products_id and mtpd.language_id = '" . $_SESSION['languages_id'] . "'";

ZenCart/includes/index_filters/default_filter.php 28行目付近から42行目付近

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = '1', s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = '1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
      } else {
// We show them all
        $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = '1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
      }
    } else {
// show the products in a given categorie
      if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
      {
// We are asked to show only specific catgeory
        $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = '1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
      } else {
// We show them all
        $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status ='1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

また、MySQLのcharacter_setが下記のようだったらZenCart/includes/classes/db/mysql/query_factory.phpの39行目付近でSET NAMEでujisを指定してやる。

character_setがutf8だったらujis指定しなければ当然ZenCartでは文字化けするはずである。

mysql> SHOW VARIABLES LIKE 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

ZenCart/includes/classes/db/mysql/query_factory.php の39行目付近に下記を追加。

mysql_query("SET NAMES ujis");

トラックバック

このエントリーのトラックバックURL:
http://jpaccess.net/cgi-bin/blog/mt-tb.cgi/388

この一覧は、次のエントリーを参照しています: ZenCart1.2.xで1054 - Unknown column 'p.products_id' in 'on clause'のエラー:

» ZenCart/1054 - Unknown column 'p.products_id' in 'on clause' 送信元 覚え書き Plus! (PukiWiki/TrackBack 0.3)
MySQL5.0xにアップグレードしたらこのエラーでカテゴリーをクリックしても表示されない現象 ここから抜粋。 記事をこちらに移動させました。 [詳しくはこちら]

コメント (2)

難しすぎてよくわかりませぬ^^

NOCCHI:

すみやさん♪
お久しぶりです^^

はい。。。(^^;
たまにこういった覚え書きを書いてます(^^;(^^;(^^;

コメントを投稿

About

2008年03月07日 19:38に投稿されたエントリーのページです。

ひとつ前の投稿は「知っていた事だけどなかなか実行できなかった(台所編)」です。

次の投稿は「市民活動情報誌 コラボレーションVol6が発行されました(゜∀゜)」です。

他にも多くのエントリーがあります。メインページアーカイブページも見てください。

Powered by
Movable Type