Welcome Guest, Not a member yet? Register   Sign In
Problem by select from db when there is a space followed by a comma in where clause
#5

[eluser]Libelle[/eluser]
Simple testcase

1. Create table mytable in your mysql database
Code:
CREATE TABLE IF NOT EXISTS `mytable` (
  `name` varchar(10) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

2. Insert a row
Code:
INSERT INTO `mytable` (`name`) VALUES ('aaa , bbb');

3. Controller
Code:
<?php
class Test extends CI_Controller {

function index()
{
  $this->load->model('Test_model');
  $query = $this->Test_model->myfunc();
  foreach ($query->result() as $row) {
   echo $row->name;
  }
}
}
?>


4. Model
[code]<?php
class Test_model extends CI_Model {

function myfunc()
{
$this->db->select('name from mytable where name like "


Messages In This Thread
Problem by select from db when there is a space followed by a comma in where clause - by El Forum - 02-16-2012, 11:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB