DB Insert Problem: Unknown Column - Column never referenced in 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

The error is (from firebug):

<p>Error Number: 1054</p><p>Unknown column 'delivery_detail.poID' in 'where clause'</p><p>UPDATE `status_order` SET `status` = 'Stock', `stockDate` = 1272214095 WHERE `poID` = '52988'</p> </div>

CI Code:
function convertToStock ($poID=null) {
        if ($poID) {
        } else {
function convertStock($poID) {
        $orderArray = Array (
            'status' => 'Stock'
            ,'stockDate' =>now()
        $this->db->where('poID', $poID);
        $tallyArray = Array (
            'tallyStatus' => 'Stock'
            ,'stockDate' =>Now()
        $this->db->where('poID', $poID);
        return true;

I don't see how another table name could come in there, except if you were creating a db query somewhere else in your code that isn't finished.
The database class will remember parts of queries you are building, until you give a command like get() or update().

So it would go wrong if your controller contained code like this:
// here you are doing something about a delivery

// now you are calling convert to stock
$this->convertToStock();   // but the 'from' information is still in the database library!

// and now you are finishing the query about delivery

I agree and that is why I am baffled. The other thing too is that the code is initiated by an AJAX call. The AJAX call is calling the right controller and procedure.

And from the error it is building the correct query but throwing in that table designation. In my controllers/models I am not mixing things up. Each table/module has its own controller and model. So this controller/model has no reference to delivery_detail....

All I can think is perhaps MySQL is caching something????? But if that is the case I would think it would cache it for a number of things, not just this piece of code. Maybe I should just call out the table first somehow?


I had a trigger in the database that is making the bad reference.

I can't believe there is caching going on between requests. I think the problem must be somewhere in the code of the Controller, Model or maybe in their constructors?

To check, you could write
at the top of your convertStock method.
These commands will clear CI's internal query building.
So if there was some loose, unfinished query, it should be cleaned up by this.

You found the problem already. Well done.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.