Welcome Guest, Not a member yet? Register   Sign In
Baffling, sporadic error message - validation issue?
#1

[eluser]novice32[/eluser]
On occasion, my CI application throws a very strange and baffling error message. My front-end application is Adobe Flex based and passes data to the CI app via HTTP post methods. In the case of this one model method, AddItem, it throws a DB error message.

------log files for one day----
ERROR - 2010-07-02 15:01:41 --> Query error: Column 'ItemClientID' cannot be null
ERROR - 2010-07-02 15:01:51 --> Query error: Column 'ItemClientID' cannot be null
ERROR - 2010-07-02 15:03:12 --> Query error: Column 'ItemClientID' cannot be null
-----------

It's important to note this happens RARELY (once a week at most). The method has been called successfully 2,000+ times, since the launch of the application. Further confusing this is ItemClientID is assigned at login (in the "user" table for each login) and should never be "null". (ItemClientID is essentially, used to identify which client inserted the record).

Am I incorrectly validating ItemClientID ??


Code:
<?php
/***** CONTROLLER CLASS *****/
class Item extends Controller {

    private $ClientID; //each client has a unique id

    function Item() {
        parent::Controller();

        ......
        
        $this->ClientID = $this->input->post('ClientID'); //reads value when HTTP post is performed to controller's AddItem method
        
        if (empty($this->ClientID)) {
            echo json_encode(array('error'=>'ClientID is required'));
            return; //exit
        }
        ....    
    }    
    
    function AddItem() {
        ...
        // read a bunch of HTTP post values and validate.
        .....
        $this->load->model('Item_model', '', TRUE);
        $rowcount = $this->Item_model->AddItem($this->ClientID,$ItemDescription,....);

        echo json_encode(array('rowcount'=>$rowcount));
    }
}

<?php
/***** MODEL METHOD ****/
class Item_model extends Model {

    function Item_model() {
        parent::Model();
    }
    
    function AddItem($ItemClientID,$ItemDescription,...) {

            //array fields are required in the db schema
            $data = array(
                    'ItemClientID' => $ItemClientID ,
                    'ItemDescription' => $ItemDescription ,
                    ....
            );

            ....

            $this->db->insert('item', $data);
            return $this->db->affected_rows();
        }
}


Messages In This Thread
Baffling, sporadic error message - validation issue? - by El Forum - 07-08-2010, 08:12 PM
Baffling, sporadic error message - validation issue? - by El Forum - 07-09-2010, 11:50 AM
Baffling, sporadic error message - validation issue? - by El Forum - 07-15-2010, 05:33 PM
Baffling, sporadic error message - validation issue? - by El Forum - 08-13-2010, 11:47 AM
Baffling, sporadic error message - validation issue? - by El Forum - 08-15-2010, 10:07 AM
Baffling, sporadic error message - validation issue? - by El Forum - 08-15-2010, 10:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB