Update database and all table character and collate utf-8
文章推薦指數: 80 %
//var_dump($table);die;. $alter_string = "ALTER TABLE $table->Tables_in_drupal7_dev CHARACTER SET utf8 COLLATE utf8_general_ci";. db_query($alter_string);. Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. pvmchau/alter_db.php CreatedOct4,2012 Star 0 Fork 0 Star Code Revisions 2 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP Updatedatabaseandalltablecharacterandcollateutf-8 Raw alter_db.php ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters fetchAll(); dsm($result); foreach($resultas$table){ //var_dump($table);die; $alter_string="ALTERTABLE$table->Tables_in_drupal7_devCHARACTERSETutf8COLLATEutf8_general_ci"; db_query($alter_string); //db_query('ALTERTABLE\':tablename\'CHARACTERSETutf8COLLATEutf8_general_ci',array(':tablename'=>$table->Tables_in_drupal7_dev)); } db_query('ALTERTABLEnodeMODIFYtitleVARCHAR(255)CHARACTERSETutf8COLLATEutf8_general_ci'); db_query('ALTERTABLEnode_revisionsMODIFYtitleVARCHAR(255)CHARACTERSETutf8COLLATEutf8_general_ci'); db_query('ALTERDATABASE$DBCHARACTERSETutf8COLLATEutf8_general_ci'); Raw updatedb.sh ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters #!/bin/bash USER=user PASSWORD=password DB=db doAllTables(){ #getthetablenames TABLENAMES=`mysql-u$USER-p$PASSWORD-D$DB-e"SHOWTABLES\G;"|grep'Tables_in_'|sed-n's/.*Tables_in_.*:\([_0-9A-Za-z]*\).*/\1/p'` #loopthroughthetablesandconvertthem forTABLENAMEin$TABLENAMES do mysql-u$USER-p$PASSWORD-D$DB-e"ALTERTABLE$TABLENAMECHARACTERSETutf8COLLATEutf8_general_ci;" done mysql-u$USER-p$PASSWORD-D$DB-e"ALTERTABLEnodeMODIFYtitleVARCHAR(255)CHARACTERSETutf8COLLATEutf8_general_ci;" mysql-u$USER-p$PASSWORD-D$DB-e"ALTERTABLEnode_revisionsMODIFYtitleVARCHAR(255)CHARACTERSETutf8COLLATEutf8_general_ci;" } doAllTables mysql-u$USER-p$PASSWORD-D$DB-e"ALTERDATABASE$DBCHARACTERSETutf8COLLATEutf8_general_ci;" Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1HTML Unicode (UTF-8) Reference - W3Schools
HTML5 UTF-8 Character Codes ; Latin Extended-A, 256-383, 0100-017F ; Latin Extended-B · 384-591, ...
- 2✔️ ❤️ ☆ Unicode Character Table
Unicode Character Table. English ... Encoding takes symbol from table, and tells font what should...
- 3How to support utf8 characters in a utf8 mysql table - Freshworks
UTF8 in MySQL. Our databases and the underlying tables were all created with utf8 encoding to ens...
- 4UTF-8 code page - Charset.org
- 5UTF-8 - Wikipedia
UTF-8 is a variable-width character encoding used for electronic communication. Defined by the Un...