Update database and all table character and collate utf-8

文章推薦指數: 80 %
投票人數:10人

//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.



請為這篇文章評分?