Hi i have an app on Joomla + php + Mysql. The array passed into function where it will be insert into mysql database. Following are my code.
public function setItems($params,$type)
{
$search_id = 1;
$query = $db->getQuery( true );
$columns = array('query_type','query_name','search_id');
foreach($params['banks'] as $key=>$value){
$values = array($db->quote('bank'), $db->quote($value), $db->quote($search_id));
$query->insert($db->quoteName('#__bank_parameters'))
->columns($db->quoteName($columns))
->values(implode(',',$values));
$db->setQuery($query);
$db->query();
}
}
The output of params as follow:
Array
(
[0] => bank1
[1] => bank2
)
The issues now, i am only getting one data insertion, not 2 as how the params above has. What might be missing here? Thanks
$query = $db->getQuery( true );again inside the loop before the second go round?$dbdefined?