cakephp 1.2 - Get a field length in mysql for query -
i'm using cakephp 1.2, , have situation: have table has 'class' field, class can 'a','b','c','g', or string of 3 letters 'dbb','aba', etc. every string has sense (for example, = article, b = book, etc). write code:
if ($_get['classificazione']!="art0") { $classificazione=$_get['classificazione']; if ($classificazione=="a"||$classificazione=="b"||$classificazione=="c"||$classificazione=="g") $conditions[]=array('classe =' => "$classificazione");
this working 'one letter' case, don't know 2 or more letters. since don't care if equals ('dbb' , 'aba' both documents), thinking check length tried this:
else $conditions[]=array('length(classe) > 1'); }
i tested else, , it's working.
use length() checking length in bytes:
select str sometable length(str) = 5;
or char_length() checking length in number of characters (useful multi-byte strings):
select str sometable char_length(str) = 5;
mysql cakephp-1.2
No comments:
Post a Comment