I am writing a web application using PHP. For the first time I started using Propel ORM. I am reading values from array and sending them to a function which has Propel Insert Queries. The function is like this.
public function someFunction
{
$nid=10;
$sample_array = array("first","second");
foreach($sample_array as $items){
$this->saveTags($items,$nid);
}
}
public function saveTags($tags,$nid)
{
error_log("SetTag: ".$this->tags->setTag($tags));
error_log("SetNid: ".$this->tags->setNid($nid));
error_log("Save: ".$this->tags->save());
}
When I execute the program, the first item "first" saves but immediately overwritten by second item i.e "second". Below are the apache error logs.
SetTag: Tid: null
Nid: null
Tag: first
SetNid: Tid: null
Nid: 30
Tag: first
Save: 1
SetTag: Tid: 11
Nid: 30
Tag: second
SetNid: Tid: 11
Nid: 30
Tag: second
Save: 1
As you can see the first item is replaced by second item! Any solution to prevent this?
Thanks