How to write a "WHERE" condition with AND in joomla 1.7? I do not have data to update

Please suggest me to write in Joomla a method for the UPDATE database with the where & clause

I write;

$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 );

I have nothing safe and the error is something like this; ......... .......... ........ [something earlier] ....

 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

}

+5
source share
2 answers

I'm not sure about the Joomla update request, but I think it is something like this: -

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

or: -

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

You have to use

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

All Articles