zen cart 訂單搜尋功能,使用中文關鍵字搜尋,出現 Illegal mix of collations for o_PHP教程

來源:互聯網
上載者:User
zen cart版本為1.3.9

進入zen cart後台,客戶管理-》訂單管理,使用訂單搜尋功能,關鍵字為中文:李超,搜尋時出現如下錯誤:

1271 Illegal mix of collations for operation 'like'
in:
[select count(*) as total from (zc_orders_status s, zc_orders o ) left join zc_orders_total ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') where (o.orders_status = s.orders_status_id and s.language_id = '2') and (o.customers_city like '%李超%' or o.customers_postcode like '%李超%' or o.date_purchased like '%李超%' or o.billing_name like '%李超%' or o.billing_company like '%李超%' or o.billing_street_address like '%李超%' or o.delivery_city like '%李超%' or o.delivery_postcode like '%李超%' or o.delivery_name like '%李超%' or o.delivery_company like '%李超%' or o.delivery_street_address like '%李超%' or o.billing_city like '%李超%' or o.billing_postcode like '%李超%' or o.customers_email_address like '%李超%' or o.customers_name like '%李超%' or o.customers_company like '%李超%' or o.customers_street_address like '%李超%' or o.customers_telephone like '%李超%' or o.ip_address like '%李超%')]

從SQL語句方面分析這個問題,發現是 o.date_purchased like '%李超%' 導致整個SQL語句執行報錯

在 MySQL 5.5 以上, 若欄位 Type 是 time,date,datetime

在 select 時若使用 like '%中文%' 會出現 Illegal mix of collations for operation 'like'

在寫程式時要對每個欄位進行搜尋,在執行時可能就會出現時間欄位 like '%中文%' 這種文法,

這在比較久的版本MySQL是不會出現錯誤的。但是升級到MySQL 5.5以上,必需改成like binary '%中文%' 即可避免出現錯誤

http://www.bkjia.com/PHPjc/440430.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/440430.htmlTechArticlezen cart版本為1.3.9 進入zen cart後台,客戶管理-》訂單管理,使用訂單搜尋功能,關鍵字為中文:李超,搜尋時出現如下錯誤: 1271 Illegal mi...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.