SkyBreak* Posted September 12, 2011 Report Share Posted September 12, 2011 Sveiki, saksāros ar MSSQL vienu problēmu.. Mazliet par sitāciju. Lietoju codeigniter mssql db klasi. Datubāzē field type ir ntext. Pēc parasta SELECT no datubāzes izmetās erros - "Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library" . Pēc tam lasīju internetā, ka vajag ntext tipu uz text datubāzē pārmainīt. Izdarīju tā, bet tad atkal nākamā problēma, jo man datubāzē visi ieraksti ir cyrillic'ā .. Pēc tipa nomainīšanas visi ieraksti palika - ???? . Meklēju talāk risinājumu, atradu funkciju CAST.. Mans querys izskatās šādi: SELECT question_id, id, question_right_answer, CAST(question_text AS text) as question_text, CAST(question_answer_1 AS text) as question_answer_1, CAST(question_answer_2 AS text) as question_answer_2, CAST(question_answer_3 AS text) as question_answer_3, CAST(question_answer_4 AS text) as question_answer_4 FROM [exam].[dbo].[questions_russian] WHERE question_id = 1149 Lai nerastos jautājumi kapēc man tāda datubāze, tapēc, ka codeigniter MSSQL klase mazliet čakarejas, tapēc rakstu pilnu nosaukumu ar visiem escape tagiem.. Izmet erroru - "Must specify table to select from. SELECT *" Biju arī mēģinājis savādāku allias likt - CAST(question_answer_4 AS text) as question_answer_4_alias, bet vienalga, tas pats. Problēma man diezgan steidzama, tapēc ļoti ceru, ka kādam ir kāda ideja, kā to novērst, paldies... Quote Link to comment Share on other sites More sharing options...
daGrevis Posted September 12, 2011 Report Share Posted September 12, 2011 Attiecīgajam kverijam neizmanto CI iebūvēto datubāzes modeli. Izmanto, kaut vai, PDO. Quote Link to comment Share on other sites More sharing options...
SkyBreak* Posted September 12, 2011 Author Report Share Posted September 12, 2011 (edited) Ar pilku mssql funkciju $query = "SELECT question_id, id, question_right_answer, CAST(question_text AS text) as question_text, CAST(question_answer_1 AS text) as question_answer_1, CAST(question_answer_2 AS text) as question_answer_2, CAST(question_answer_3 AS text) as question_answer_3, CAST(question_answer_4 AS text) as question_answer_4 FROM questions_russian WHERE question_id = 1149"; $result = mssql_query($query); $row = mssql_fetch_array( $result ); print_r($row); Rezultāts: Array ( [0] => 1149 [question_id] => 1149 [1] => 1027.0 [id] => 1027.0 [2] => 2 [question_right_answer] => 2 [3] => ??????????? ?? ??? ???????? ???????? ?????? ??? ??????????? ???????? ?????? ?????????? ????????? ???????? ?? ???????? ??????, ???????????? ?? ???????? [question_text] => ??????????? ?? ??? ???????? ???????? ?????? ??? ??????????? ???????? ?????? ?????????? ????????? ???????? ?? ???????? ??????, ???????????? ?? ???????? [4] => ???????????. [question_answer_1] => ???????????. [5] => ???????????. [question_answer_2] => ???????????. [6] => [question_answer_3] => [7] => [question_answer_4] => ) Pameiģināju kādu no field'iem bez CAST funkcijas, tad parāda to pašu, bet ar erroru. WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?'). (severity 16) in EDITED: Pievienoju augšā.. - > ini_set('mssql.charset', 'UTF-8'); [question_right_answer] => 2 [3] => РазрешаетÑÑ Ð»Ð¸ Вам подавать звуковой Ñигнал Ð´Ð»Ñ Ð¿Ñ€Ð¸Ð²Ð»ÐµÑ‡ÐµÐ½Ð¸Ñ Ð²Ð½Ð¸Ð¼Ð°Ð½Ð¸Ñ Ð´Ñ€ÑƒÐ³Ð¸Ñ… учаÑтников дорожного Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ Ð·Ð° дорожным знаком, изображенным на риÑунке? [question_text] Ir idejas, kā varētu dabūt ko lasāmāku :) ? Edited September 12, 2011 by SkyBreak* Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted September 13, 2011 Report Share Posted September 13, 2011 (edited) Iespējams ka cast() tur nav pie vainas, bet kaut kas ar collation ir saplīsis/nesakrīt. Vispirms paskaties kādi ir pieejami SELECT * FROM fn_helpcollations(); Pēc tam pamēģini kādu no viņiem, kas izklausās derīgs SELECT question_text COLLATE <te kāds no fn_helpcollations().name> FROM ... Edited September 13, 2011 by v3rb0 Quote Link to comment Share on other sites More sharing options...
SkyBreak* Posted September 13, 2011 Author Report Share Posted September 13, 2011 (edited) Parāda tikai Array ( [0] => Albanian_BIN [name] => Albanian_BIN [1] => Albanian, binary sort [description] => Albanian, binary sort ) Izmet tikai kkādu Albian :) neizklausās, ka derētu, mssql db taisīts uz Latvian_CI_AI. Problēmas ir mssql serverī ? Edited September 13, 2011 by SkyBreak* Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted September 13, 2011 Report Share Posted September 13, 2011 izpildi ar ko tādu, kas parāda visas rezultāta rindas :) Quote Link to comment Share on other sites More sharing options...
roleeks Posted September 13, 2011 Report Share Posted September 13, 2011 (edited) Tas esmu es, topika autors, viekārši tagad savs profils, jo iepriekš reCHAPTA negaja (: ini_set('mssql.charset', 'UTF-8'); mssql_connect("****", "****", "****") or die(mssql_error()); mssql_select_db("*****") or die(mssql_error()); $query = "SELECT question_text COLLATE Cyrillic_General_CI_AI FROM questions_russian WHERE question_id = 1149"; $result = mssql_query($query); $row = mssql_fetch_array( $result ); print_r($row); Mēģinājums vairākus cyrllic collate's mainīt, vispār, bez izmaiņam! Pagaidām ir sitācija tāda, ka mājaslapu taisu uz Linux Gentoo, Apaches, bet mājaslapas pasūtītājām stāvēs uz IIS,, Varbūt ir iespēja, ka tur viss strādās kā vaig :) ? Edited September 13, 2011 by roleeks Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted September 13, 2011 Report Share Posted September 13, 2011 nav kaut kas pavisam dumš, piemēram, kāds encodings lapai, ir utf-8? Quote Link to comment Share on other sites More sharing options...
roleeks Posted September 13, 2011 Report Share Posted September 13, 2011 (edited) Tiešām, dokumentam nebiju uzlicis charset, jo testēju parasto query'u iekš tukša php faila :/ Bet vienalga, paldies par to codeigniter problēmu.. Edited September 13, 2011 by roleeks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.