I'm having a small issue getting an index defined for use in a DB2 query in php.
The below script functions except for the portion where I'm trying to put DB2 results in an array and print them. Instead of printing the array, it prints the error shown below in /**/
. Specifically, an illegal string offset of order_id in my where clause.
The mysql portion, as far as selecting and updating, works perfectly.
However, for all of the order_ids in $order_ids, I want to use that variable to match them in the db2 query and then get all of the SELECT results from DB2 in an array so that I can check to make sure the array contains the data for all of the right orders/records.
Possibly just an issue with passing the variables to DB2 but I've been doing so much with DB2 in PHP the last few days that I'm starting to have a hard time pin pointing things, since DB2 isn't something I've ever worked with.
How can I change this to use the $order_ids[] = $row['order_id'] and match it to the invnoc column in db2?
$orderShippedCheck = "
SELECT
order_id,
order_status
FROM order_status
WHERE order_status = 'S'
";
$result = mysqli_query($mysqlConn, $orderShippedCheck);
$order_ids = array();
//loop results to gather order IDs and store them
while ($row = mysqli_fetch_array($result)){
$order_ids[] = $row['order_id'];
}
print_r($order_ids);
//Update those records to show they were made placements, and update the date
foreach($order_ids as $order_id){
$updatePlacement = "UPDATE order_status SET is_placement = 1, date_updated = DATE(NOW()) WHERE order_id = '$order_id';";
//SELECT FROM DB2 WITH THE ORDER NUMBERS FIRST
$DB2Shipped = "
SELECT
invnoc as INVOICE,
cstnoc AS DEALER,
framec AS FRAME,
covr1c AS COVER,
colr1c AS COLOR ,
extd2d AS SHIPDATE,
orqtyc AS QUANTITY
FROM GPORPCFL
WHERE invnoc = '{$order_id['order_id']}'
group by invnoc,cstnoc, slsnoc, orqtyc, framec, covr1c,colr1c, extd2d
order by invnoc asc
";
print_r($order_id);
$Db2ShipRslt = odbc_exec($DB2Conn,$DB2Shipped);
if ( $Db2ShipRslt === false ) {
exit (odbc_errormsg($DB2Conn));
}
$Db2ShipArr = array();
print_r($order_id); /*This prints the order ID for each record*/
print_r($Db2ShipArr); /*This prints an empty array, Array()*/
while($db2ShipRow = odbc_fetch_array($Db2ShipRslt)){
{
$Db2ShipArr[] = $db2ShipRow['INVOICE'];
}
foreach($Db2ShipArr as $Db2Ship){
print_r($Db2ShipArr);
}
}