The Joomla! Forum ™






Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Joomla / MYSQL
PostPosted: Thu Aug 19, 2010 1:04 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 21, 2005 4:22 pm
Posts: 15
Hi people of Slovenia (sorry to write in english but I can't do it in slovenian)
I have some issues with PHP queries coming from Joomla and using slovenian characters like Č, Š and Ž.
Actually, I currently develop a module which needs to access the dbase with a query like the following:

Example
Code:
SELECT *
FROM `jos_people`
WHERE `lastname` LIKE 'Š%'
LIMIT 0 , 30


The problem is that this kind of query returns all words starting by "S" and "Š".
But I want only words starting by "Š".

Do you know if there is a way to force the query to search only this kind of characters (Č, Š and Ž and not C, S and Z.) ?

Thanks a lot for your answers if any.

Shemzone (from France)


Top
 Profile  
 
 Post subject: Re: Joomla / MYSQL
PostPosted: Fri Aug 20, 2010 2:52 am 
Joomla! Explorer
Joomla! Explorer

Joined: Sat Oct 10, 2009 2:28 pm
Posts: 413
Location: Medellin, Colombia
what is your MySQL connection collation? via phpmyadmin...it should work with utf8_unicode_ci..but there are other choices...

_________________
Retired IBM 360/370 Assembler TPF Systems Programmer


Top
 Profile  
 
 Post subject: Re: Joomla / MYSQL
PostPosted: Tue Aug 24, 2010 8:22 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 21, 2005 4:22 pm
Posts: 15
azunoman wrote:
what is your MySQL connection collation? via phpmyadmin...it should work with utf8_unicode_ci..but there are other choices...


Hi Azunoman,
my MySQL connection collation is indeed utf8_unicode_ci
See the issue there:
http://cust04.shemzone.com/
Then click on the penultimate horizontal menu " Avtorji" (meaning "Authors" in Slovenian), then click on the letter S or Š => same result.
Here is how I build the alphanumerical bar: (example for D to S)
Code:
for ($char=68;$char<=83;$char++){ //D to S
   if (chr($char)==$letter){
         echo " | <span style=\"font-weight:bold;color:#999;text-decoration:underline;\">".chr($char)."</span>";
   }else{
      if (getListWriterbyLetter(chr($char))>0){
         echo (" | <a href='".$mm_action_url."index.php?option=com_virtuemart&amp;Itemid=$Itemid&amp;page=$modulename.browse&amp;list_writers=".$list_writers."&amp;letter=".chr($char)."' title='".chr($char)."'><span style=\"font-weight:bold;\">".chr($char)."</span></a>");
      }else{
         echo " | <span style=\"color:#999;\">".chr($char)."</span>";
      }
   }
}


and for the Slovenian character
Code:
//Slovenian only
if($slovenian){
   $slovenianArr=array("Š");
   foreach ($slovenianArr as $i => $value) {
      if (($slovenianArr[0]==$letter)){
               echo " | <span style=\"font-weight:bold;color:#999;text-decoration:underline;\">".$slovenianArr[0]."</span>";
         }else{
            if (getListWriterbyLetter($slovenianArr[0])>0){
               echo (" | <a href='".$mm_action_url."index.php?option=com_virtuemart&amp;Itemid=$Itemid&amp;page=$modulename.browse&amp;list_writers=".$list_writers."&amp;letter=".$slovenianArr[0]."' title='".$slovenianArr[0]."'><span style=\"font-weight:bold;\">".$slovenianArr[0]."</span></a>");
            }else{
               echo " | <span style=\"color:#999;\">".$slovenianArr[0]."</span>";
            }
      }
   }
}


And (a part of) the SQL query:
Code:
$query =  "SELECT COUNT(DISTINCT #__{vm}_bookshop_writer.writer_id) as num_rows_writers ";
            $query .= "FROM #__{vm}_bookshop_writer, #__{vm}_bookshop_product_writer_xref, #__{vm}_product ";
            $query .= "WHERE #__{vm}_bookshop_product_writer_xref.writer_id = #__{vm}_bookshop_writer.writer_id ";
            $query .= "AND #__{vm}_bookshop_product_writer_xref.product_id = #__{vm}_product.product_id ";
            $query .= "AND #__{vm}_product.product_publish='Y' ";
            $query .= "AND #__{vm}_bookshop_writer.writer_lastname LIKE '$string%' ";


I tried to collate differently but no success:
Code:
$query .= "AND #__{vm}_bookshop_writer.writer_lastname COLLATE cp1250_general_ci LIKE '$string%' ";



Any clue is welcome.

Regards
Shemzone


Top
 Profile  
 
 Post subject: Re: Joomla / MYSQL
PostPosted: Tue Aug 24, 2010 12:39 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Sat Oct 10, 2009 2:28 pm
Posts: 413
Location: Medellin, Colombia
add this in between your header tags and test:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

_________________
Retired IBM 360/370 Assembler TPF Systems Programmer


Top
 Profile  
 
 Post subject: Re: Joomla / MYSQL
PostPosted: Tue Aug 24, 2010 3:36 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 21, 2005 4:22 pm
Posts: 15
azunoman wrote:
add this in between your header tags and test:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

Added. Same thing...
Actually, it was already added (see snippet code below):
Code:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sl-si" lang="sl-si">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
...

S.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group