dimanche 28 juin 2015

PHP writing wrong value into DB?

I created the following table inside a DB

$sql = "CREATE TABLE tac_flightsize
(
    id int NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (id),

    gameid int NOT NULL,
    shipid int,
    flightsize int
 )";

I check for a DB write like this:

if (!$ship->superheavy){
   debug::log("db flight: " + $ship->flightSize);
   self::$dbManager->submitFlightSize($id, $gamedata->id, $ship->id, $ship->flightSize);
}

The debug::log entry shows 12 as the $ship->flightSize so the value is correct.

Here is the actual submitFlightSize function:

public function submitFlightSize($shipid, $gameid, $flightSize){
        try{
            $sql = "INSERT INTO `B5CGM`.`tac_flightsize` VALUES(null, $gameid, $shipid, $flightSize)";
            $id = $this->insert($sql);
            Debug::log($sql);

        }catch(Exception $e) {
            $this->endTransaction(true);
            throw $e;
        }
}

The Debug:::log from this function shows the follow SQL entry

INSERT INTO `B5CGM`.`tac_flightsize` VALUES(null, 2535, 16238, 1) 

Now, the last parameter is 1, when it should be 12 and was a second ago according to the earlier debug.

Can anyone explain to me what i might be doing wrong ?

Aucun commentaire:

Enregistrer un commentaire