【问题标题】:scape value queryscape值查询
【发布时间】:2013-01-22 12:44:18
【问题描述】:

大家好,在我的 getListQuery() 方法中,我的这个查询 en SQL 有错误,因为我不知道如何转义 $language 值

$query->from('`#__noticias` AS a');
$query->where('( a.idioma LIKE '.$language.' )');

我想得到这个。

$query->from('`#__noticias` AS a');
$query->where('( a.idioma LIKE "es-ES" )');

任何想法!

【问题讨论】:

  • 投反对票,因为标签表示 SQL,但这里显然还有其他平台在起作用,因为那不是 SQL。

标签: joomla2.5


【解决方案1】:

去做吧

 $lan = $db->Quote('%'.$db->escape($language, true).'%');

终于

    $db = $this->getDbo();
    $query = $db->getQuery(true);
    $language =& JFactory::getLanguage()->getTag();
    $lan = $db->Quote('%'.$db->escape($language, true).'%');

    // Select the required fields from the table.
    $query->select(
            $this->getState(
                    'list.select', 'a.*'
            )
    );

    $query->from('`#__noticias` AS a');
    $query->where('( a.idioma LIKE '.$lan.' )');

【讨论】:

    猜你喜欢
    • 2021-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-27
    • 1970-01-01
    • 2020-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多