Skip to content

Instantly share code, notes, and snippets.

@oshanz
Created January 31, 2014 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oshanz/8732618 to your computer and use it in GitHub Desktop.
Save oshanz/8732618 to your computer and use it in GitHub Desktop.
validate insert
public function placeStockProduct($dataArray) {
print_r($dataArray);
$count = $dataArray['count2'];
$sql = "INSERT INTO `outlet_stock_check` (`outlet_name`, `outlet_id`, `product_name`, `product_id`, `qty`) VALUES ";
$do = FALSE;
for ($index = 0; $index < $count; $index++) {
if (isset($dataArray['product_name_' . $index]) && !empty($dataArray['product_qty_' . $index])) {
$sql.="('', '', '" . $dataArray['product_name_' . $index] . "', ''," . $dataArray['product_qty_' . $index] . ")";
if (!$do) {
$do = TRUE;
}
if ($index+1 < $count) {
$sql.=",";
}
}
}
if ($do) {
echo $sql;
// $this->db->query($sql);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment