dougaxing8673 2014-03-24 13:17
浏览 10

无法使查询与变量一起工作

i have this query

AND i.state = 1
AND i.language = "'.$mylang.'"
AND i.access IN ('.implode(',', $user->getAuthorisedViewLevels()).')

i should get the content only for the current language) the strange thing is that with the php variable $mylang it's not working ( writing it-IT ) i get the content. I allready checked the result of $mylang and its = to it-IT .

any clues? thanks.

  • 写回答

1条回答 默认 最新

  • douan6931 2014-03-25 03:26
    关注

    I'm not sure about the 1=1 subclause in your WHERE but ignoring that Try something like this:

    $db = JFactory::getDBO();
    $query = $db->query(true);
    $query->select('i.*')
        ->from($db->quteName('#__content')) 
        ->where($db->quoteName('i.state') . ' = 1')
        ->where($db->quoteName('i.language') .' = '  $db->quote($mylanguage))
        ->where($db->quoteName('i.access') . ' IN (' . impode(',',$user->getAuthorisedViewLevels()) . ')' )
     ...
    ;
    $db->set($query);
    ....
    

    Also, if your queries are not working the best thing is to do echo $query->dump() to see the rendered query, also you can just look at the queries if you turn the debugger on.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题