Search code examples
phporaclepear

trying to update Oracle records with timestamp from php pear


So I want to loop through all records in a table updating the timestamp column with CURRENT_TIMESTAMP. But it times out in the browser.

function TEST_Module(){
    $stockScaned = DB_DataObject::factory('StockScanned');
    $number_of_rows = $stockScaned->find();
    while ($stockScaned->fetch()) {
        $sql =
            <<<SQL
UPDATE "StockScanned"
SET "scanDateTime" = CURRENT_TIMESTAMP;
SQL;
        $stockScaned->query($sql);
        $updatedRows = $stockScaned->update();
    }
}

any ideas please?

UPDATE:
It does not time out anymore, but its not updating the database.
I removed the ; from the end of the query.
I've created a new data object for the update and also querying by ID, but alas....

function TEST_Module(){
    $stockScaned = DB_DataObject::factory('StockScanned');
    $number_of_rows = $stockScaned->find();
    while ($stockScaned->fetch()) {
        $id = $stockScaned->id;
        $sql =
            <<<SQL
UPDATE "StockScanned"
SET "scanDateTime" = CURRENT_TIMESTAMP
WHERE id = $id
SQL;
        $stockScanedNEW = DB_DataObject::factory('StockScanned');
        $stockScanedNEW->query($sql);
        $updatedRows = $stockScanedNEW->update();
    }
}

Solution

  • Okay.

    $dumbUserError = new FacePalm()
    

    I did not put the where clause id in quotes.