开发者

How do i pass small Case parameter to query

    $this->db->select开发者_开发技巧("ID");
    $whereCondition = array('CITY' =>$this->db->escape_like_str($cityName) , 'STATUS'=>'A');
    $this->db->where($whereCondition); 

In the above code snippet want to perform where codition operation in small case letter

My DB Field Value is "Mumbai" and Actual Value "Mumbai" want to convert it to mumbai mumbai.

How do i do this using code ignitor


You could run your 'string' through the PHP function strtolower()

  • http://us2.php.net/manual/en/function.strtolower.php

Example:

<?php
$str = "Mary Had A Little Lamb and She LOVED It So";
$str = strtolower($str);
echo $str; // Prints mary had a little lamb and she loved it so
?>

EDIT

In case I read it wrong, as I re-read it now, you want your DB value to be compared? I do believe that mysql is case insensitive by default. So your Mumbai will equal mubmai when compared Mumbai = mumbai in mysql.


If I have got your question right. I suggest the following:

For the column name:

ALTER TABLE table_name RENAME column_name TO LOWER(column_name);

For the field value:

UPDATE table_name SET Column_name=LOWER(Column_name) WHERE Column_name LIKE 'Mumbai';

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜