微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mysql – 如何在joomla 1.7中使用AND编写’WHERE’子句条件?我没有数据保存更新

请建议如何在joomla中使用AND编写以下UPDATE查询.

码:

$query = JFactory::getDbo()->getQuery(true);
$db =& JFactory::getDBO();
$query->update('table1');
$query->set('id = ' . $db->quote($idname));
$query->set ('day='. $db->quote($this->_day));
$query->set('id2 = ' . $id2);

$query->where('id = '. (int)$idname)
        AND('id2=' .(int)$id2 );

更新失败,错误是这样的:

//........[something before ]....

array(3) {
    [0]=>
    string(11) "id = '1'"
    [1]=>
    string(14) "id2='2'"
    [2]=>
    string(17) "date = 2012-04-02"    [it seems i got all the value pass to be update]
  }
  ["glue:protected"]=>
  string(4) ","
}
["where:protected"]=>
object(JDatabaseQueryElement)#251 (3) {
  ["name:protected"]=>
  string(5) "WHERE"
  ["elements:protected"]=>
  array(1) {
    [0]=>
    string(14) "id = 2"  [where clause is ok  ...BUT with AND...]
  }
  ["glue:protected"]=>   
  string(5) " AND "
}
["group:protected"]=>  [something is wrong here...?]
NULL
["having:protected"]=>
NULL
["columns:protected"]=>
NULL
["values:protected"]=>
NULL
["order:protected"]=>
NULL
["autoIncrementField:protected"]=>
NULL
}
最佳答案
我不确定Joomla更新查询,但我认为它是这样的: –

$query->where('id = '. (int)$idname);
$query->AND('id2=' .(int)$id2 );

要么:-

$query->where('id = '. (int)$idname . 'AND id2 = '.(int)$id2);

原文地址:https://www.jb51.cc/mysql/433318.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐