Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.