Hi I'm using this code to insert multiple records. The code executes but nothing is entered into my database. This usually happens when there's a mismatch in data types.
How do I ensure that description goes in as text which in sql is wrapped in single quotes, but also make sure the other variables go in as numeric.
// an array items to insert
$array = array( 'theid' => $theid,
'descr' => $descr,
'costperunit' => $costperunit,
'quantity' => $quantity,
'costperlot' => $costperlot
);
// begin the sql statement
$sql1 = "INSERT INTO descriptions (jobid, description, costperunit, quantity, costperlot) VALUES ";
$it = new ArrayIterator( $array );
// a new caching iterator gives us access to hasNext()
$cit = new CachingIterator( $it );
// loop over the array
foreach ( $cit as $value )
{
// add to query
$sql1 .= "('".$cit->key()."','" .$cit->current()."')";
if( $cit->hasNext() )
{
$sql1 .= ",";
}
}