codeigniter查询无效 - 响应为空

时间:2013-04-18 13:29:52

标签: sql codeigniter model

我的codeigniter模型中有以下功能:

  function get_as_09($q){
    $sql=("select length from
(SELECT  
      [length]
    ,CONCAT(([width]*1000),([thickness]*1000),REPLACE([ProductCode],concat(([width]*1000),([thickness]*1000),REPLACE((convert(varchar,convert(decimal(8,1),length))),'.','')),'')) as options

  FROM [database].[dbo].[ProductList]) as p
  where options='$q' order by length");
    $query=$this->db->query($sql);
    if($query->num_rows > 0){
        foreach ($query->result_array() as $row){
            $row_set[] = htmlentities(stripslashes($row['length'])); //build an array
       }
       return $row_set;
    }
  }

这不起作用或返回结果。

下面的sql语法确实会返回一个结果:

select length from
(SELECT  
      [length]
      ,CONCAT(([width]*1000),([thickness]*1000),REPLACE([ProductCode],concat(([width]*1000),([thickness]*1000),REPLACE((convert(varchar,convert(decimal(8,1),length))),'.','')),'')) as options

  FROM [database].[dbo].[ProductList]) as p
  where options='25100cr' order by length

我是否正确地将$ q变量传递给查询?我的语法一般是正确的吗?

一如既往地感谢您。

0 个答案:

没有答案