Link to home
Start Free TrialLog in
Avatar of TumacLumber
TumacLumber

asked on

Stumped: MySQL corruption? DB Insert failing. PHP Code referencing a column in different table, but running correct code?

I have a function that updates two tables.  In my code I pass an ID field to be updated.  The ID comes from a javascript function/application.

I have made no changes to my code and at one time a couple of weeks ago, the code was working perfectly.

The error below is referencing 'delivery_detail.poID'.  The javascript does not reference delivery_detail, the PHP does not reference delivery_detail

I am using CodeIgniter MVC framework for my PHP.


The error is (from firebug):
Error Number: 1054
Unknown column ‘delivery_detail.poID’ in ‘where clause’
UPDATE `status_order` SET `status` = ‘Stock’, `stockDate` = 1272214095 WHERE `poID` = ‘52988’  </div>

//Controller
function convertToStock ($poID=null) {
        $poID=$this->input->post('poID');
        
        if ($poID) {
        $data=$this->inTransit_model->convertStock($poID);
        $this->_printSuccessTrue($data);
        } else {
            $this->_printSuccessFalse();
        }
        
    }
............
//Model
function convertStock($poID) {
        $this->load->helper('date');
        $orderArray = Array (
            'status' => 'Stock'
            ,'stockDate' =>now()
        );
        $this->db->where('poID', $poID);
        $this->db->set($orderArray);
        $this->db->update('status_order');
        
        $tallyArray = Array (
            'tallyStatus' => 'Stock'
            ,'stockDate' =>Now()
        );
        
        $this->db->where('poID', $poID);
        $this->db->set($tallyArray);
        $this->db->update('status_tally');
        
        return true;
        
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Muhammad Khan
Muhammad Khan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TumacLumber
TumacLumber

ASKER

Aha..... no Foreign Key but I forgot it has a trigger.....The trigger is making the faulty reference.  That is the problem with not touching a piece of code for a few weeks....

Thanks.