public function saveVendorsItems($vendor_id, $shop_id, $items_data)
 {
     //echo $vendor_id."=".$shop_id;
     $iterator = new ArrayIterator($items_data);
     $cache = new CachingIterator($iterator);
     foreach ($cache as $value) {
         $key = $cache->key();
         $key_part = explode('_', $key);
         // key = entity_id+ id ; here id value mapped with pos_vendor_item_price table
         $entity_id = $key_part[0];
         $id = (int) $key_part[1];
         $price = $cache->current();
         if (!$id) {
             // when $id = 0; it's mean new entry
             $query = "INSERT INTO pos_vendor_item_price (product_id, vendor_shop_id,self_shop_id,price ) VALUES ";
             $query .= "(" . $entity_id . ",{$vendor_id},{$shop_id}," . $price . ")";
             $result = mysql_query($query);
             //if any error stop operation and exist with error message.
             if (!$result) {
                 break;
                 return false;
             }
         } else {
             $query = " INSERT INTO pos_vendor_item_price (id,product_id, vendor_shop_id,self_shop_id,price ) VALUES ";
             $query .= "(" . $id . ",{$entity_id},{$vendor_id},{$shop_id}," . $price . ")";
             $query .= " ON DUPLICATE KEY UPDATE price = VALUES(price) ";
             $result = mysql_query($query);
             if (!$result) {
                 break;
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * Override the current() method to modify the return value
  * for the given index.
  *
  * @access  public
  * @return  string
  */
 public function current()
 {
     // get the name and url of the nav item
     $name = parent::key();
     $url = parent::current();
     // determine if we're on the last element
     if ($this->hasNext()) {
         return '<li><a href="' . $url . '">' . $name . '</a></li>';
     } else {
         return '<li class="last"><a href="' . $url . '">' . $name . '</a></li>';
     }
 }
// this is internal data, no need to check for XSS
$jsonids = $_POST["ids"];
$ids = json_decode($jsonids, true);
// create db connection
$access = new dbAccess();
$access->openConnection();
// begin sql statement
$sql = "insert into notify (event_id, user_id, inviter_id) values ";
// iterate through $ids array for a single batch sql query
$iter = new ArrayIterator($ids);
// a new caching iterator gives us access to hasNext()
$citer = new CachingIterator($iter);
// loop over the array
foreach ($citer as $value) {
    // add to the query
    $sql .= "('" . $ids[$citer->key()]["event_id"] . "','" . $ids[$citer->key()]["user_id"] . "','" . $ids[$citer->key()]["inviter_id"] . "')";
    // if there is another array member, add a comma
    if ($citer->hasNext()) {
        $sql .= ",";
    }
}
// run query
$result = $access->conn->query($sql);
// report success if query succeeded
if (!empty($result)) {
    $returnValue["status"] = "Success";
    $returnValue["message"] = "Users invited";
    echo json_encode($returnValue);
} else {
    $returnValue["status"] = "error";
    $returnValue["message"] = $sql;