Quantcast
Channel: Question and Answer » wpdb
Viewing all articles
Browse latest Browse all 44

Does WP query update accept variables being built into it?

$
0
0

Trying to figure out if this is a WP specific quirk.

The var_dump code shows the correct string to be inserted but the last query dump at the end shows an incomplete query with no variable being passed it seems. So I’m not sure if this is a WP specific quirk or what could be the issue here? Does anyone have any knowledge on this?

Again the dumps show the correct string until I get to to the query string.

$numItems = count($changeorderVar);
    $i = 0;

    foreach ($changeorderVar as $changeorderVartwo ){

          if(++$i === $numItems) {
            $changeorderVarstringFinal .= "'orderfeatured' => ".$changeorderVartwo .''; 
          }
        else 
            $changeorderVarstringFinal .= "'orderfeatured' => ".$changeorderVartwo .','; 

    }
    $numItemsiii = count($updateOrder);
    $iii = 0;
    foreach ($updateOrder as $updateOrdertwo ){

            if(++$iii === $numItems) {
            $updateOrderFinal .= "'orderfeatured' => ".$updateOrdertwo;     
              }
            else 
                $updateOrderFinal .= "'orderfeatured' => ".$updateOrdertwo .',';    
    }
    echo "<div style='background:red;color:#ffffff;'><h1>jsonupdateOrderchangeorderVar = </h1><br /> ";
    var_dump($changeorderVarstringFinal);
    echo "</div>";
    echo "<div style='background:red;color:#ffffff;'><h1>jsonupdateOrderchangeorderVar = </h1><br /> ";
    var_dump($updateOrderFinal);
    echo "</div>";



    $wpdb->update( 
                'wp_hnes_table_sar_ram', 
                array($changeorderVarstringFinal),
                array($updateOrderFinal), 
                array('%d','%d','%d'),
                array( '%d','%d','%d' ) 
    );//end update

    exit( var_dump($wpdb->last_query ) );

This part of the query is not dynamic yet, but does match the number of elements.

array('%d','%d','%d'),
array( '%d','%d','%d' ) 

Viewing all articles
Browse latest Browse all 44

Trending Articles