Jump to content

Is there a way to do this?


Andy-H

Recommended Posts


                  $vehicleID = $check->fetchColumn(0);
                  $stmt = $dbh->prepare("UPDATE caravans SET 
                                    make  = (IF(LENGTH(:make), :make, make)), 
                                    model = (IF(LENGTH(:model),:model, model)), 
                                    type  = (IF(LENGTH(:type), :type, type)), 
                                    axle  = (IF(LENGTH(:axle), :axle, axle)),
                                    CRis  = (IF(LENGTH(:CRis), :CRis, CRis))
                                WHERE id = :vID LIMIT 1");
                  $stmt->bindParam(':make',  $data['make'],  PDO::PARAM_STR, strlen($data['make']));
                  $stmt->bindParam(':model', $data['model'], PDO::PARAM_STR, strlen($data['model']));
                  $stmt->bindParam(':type',  $data['type'],  PDO::PARAM_STR, strlen($data['type']));
                  $stmt->bindParam(':axle',  $data['axle'],  PDO::PARAM_STR, strlen($data['axle']));
                  $stmt->bindParam(':CRis',  $data['CRis'],  PDO::PARAM_STR, strlen($data['CRis']));
                  $stmt->bindParam(':vID',   $vehicleID,     PDO::PARAM_INT);
                  $stmt->execute();

Basically, I want the fields to update if the $data contains a value for it, the above doesn't work.

 

 

Thanks for any help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.