Issues

ZF-11355: MySQL/Zend_Db: Update statement on a TEXT field after Select statement in code: double the text inserted. ... wait... WHAT!?

Description

Hello,

I'm not entirely sure if i am running in to a bug or that i am doing something wrong myself... i've tried everything i could but up untill the point even zend framework hands over control to PDO to execute the query everything is working just fine as far as i can see.

{quote}

 
        if ($jobid) {
            $details = $Mdl_jobs->readJobs($jobid);
            $joblog = isset($details["joblog"])?($details["joblog"] . "\n". base64_decode($joblog)):base64_decode($joblog);
            echo $joblog;
        }
        // Basis kennis voor deze functie
        $date = new Zend_Date();
        $statussen = array('ready2run','running','checking','finished','missed','failed');
        
        if ($jobid && $statusupdate) {
            //echo "dit " . $previouslog . " tot";
            if ($statusupdate == "1") {
                $updateSet = array(
                    "status" => $statussen[$statusupdate],
                    "start" => $date->get('YYYY-MM-dd HH:mm:ss'),
                    "joblog" => base64_decode($joblog),
                    "used_ip" => $usingip
                );
                $save = $Mdl_jobs->saveJob( $jobid, $updateSet );
                unset($updateSet);
            } elseif ($statusupdate == "2") {
                $updateSet = array(
                    "status" => $statussen[$statusupdate],
                    "joblog" => $previouslog . "\n" . base64_decode($joblog)
                );
                $save = $Mdl_jobs->saveJob( $jobid, $updateSet );
                unset($updateSet);
            } else {
                $updateSet = array(
                    "status" => $statussen[$statusupdate],
                    "finish" => $date->get('YYYY-MM-dd HH:mm:ss'),
                    "joblog" => $joblog
                );
                $save = $Mdl_jobs->saveJob( $jobid, $updateSet );
                unset($updateSet);
                if ($statusupdate == "5") {
                    $completejob = $Mdl_jobs->readJobs($jobid);
                    $mdetails = $Mdl_machines->readMachines($completejob["machine_id"]);
                    $emailHelper->sendMail( '*', 'Backup mislukt: ' . $mdetails["hostname"], $completejob["joblog"] . "\n" . base64_decode($joblog) );
                }
            }
            if (!$save) {
                $emailHelper->sendMail( '*', 'Database Probleem', 'De database accepteerde een insert/update niet!' );
            }
        }

This code with a text quote for log insert "rara" will get injected into the database, but the contents get doubled somehow along the way, after running this piece of code the database TEXT field contains 'rara\n\nrara'... but HOW!

{quote}

 
DESCRIBE `jobs`

Array
(
)

Zend_Db_Statement_Pdo Object
(
    [_fetchMode:protected] => 2
    [_stmt:protected] => PDOStatement Object
        (
            [queryString] => DESCRIBE `jobs`
        )

    [_adapter:protected] => Zend_Db_Adapter_Pdo_Mysql Object
        (
            [_pdoType:protected] => mysql
            [_numericDataTypes:protected] => Array
                (
                    [0] => 0
                    [1] => 1
                    [2] => 2
                    [INT] => 0
                    [INTEGER] => 0
                    [MEDIUMINT] => 0
                    [SMALLINT] => 0
                    [TINYINT] => 0
                    [BIGINT] => 1
                    [SERIAL] => 1
                    [DEC] => 2
                    [DECIMAL] => 2
                    [DOUBLE] => 2
                    [DOUBLE PRECISION] => 2
                    [FIXED] => 2
                    [FLOAT] => 2
                )

            [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo
            [_config:protected] => Array
                (
                    [dbname] => backupservice
                    [username] => backup
                    [password] => **************
                    [host] => *************
                    [charset] => utf8
                    [persistent] => 
                    [options] => Array
                        (
                            [caseFolding] => 0
                            [autoQuoteIdentifiers] => 1
                        )

                    [driver_options] => Array
                        (
                            [1002] => SET NAMES 'utf8'
                        )

                )

            [_fetchMode:protected] => 2
            [_profiler:protected] => Zend_Db_Profiler Object
                (
                    [_queryProfiles:protected] => Array
                        (
                        )

                    [_enabled:protected] => 
                    [_filterElapsedSecs:protected] => 
                    [_filterTypes:protected] => 
                )

            [_defaultProfilerClass:protected] => Zend_Db_Profiler
            [_connection:protected] => PDO Object
                (
                )

            [_caseFolding:protected] => 0
            [_autoQuoteIdentifiers:protected] => 1
            [_allowSerialization:protected] => 1
            [_autoReconnectOnUnserialize:protected] => 
        )

    [_attribute:protected] => Array
        (
        )

    [_bindColumn:protected] => Array
        (
        )

    [_bindParam:protected] => Array
        (
        )

    [_sqlSplit:protected] => Array
        (
            [0] => DESCRIBE `jobs`
        )

    [_sqlParam:protected] => Array
        (
            [0] => DESCRIBE `jobs`
        )

    [_queryId:protected] => 
)

SELECT `jobs`.* FROM `jobs` WHERE (jobid = '4') ORDER BY `jobid` ASC LIMIT 1

Array
(
)

Zend_Db_Statement_Pdo Object
(
    [_fetchMode:protected] => 2
    [_stmt:protected] => PDOStatement Object
        (
            [queryString] => SELECT `jobs`.* FROM `jobs` WHERE (jobid = '4') ORDER BY `jobid` ASC LIMIT 1
        )

    [_adapter:protected] => Zend_Db_Adapter_Pdo_Mysql Object
        (
            [_pdoType:protected] => mysql
            [_numericDataTypes:protected] => Array
                (
                    [0] => 0
                    [1] => 1
                    [2] => 2
                    [INT] => 0
                    [INTEGER] => 0
                    [MEDIUMINT] => 0
                    [SMALLINT] => 0
                    [TINYINT] => 0
                    [BIGINT] => 1
                    [SERIAL] => 1
                    [DEC] => 2
                    [DECIMAL] => 2
                    [DOUBLE] => 2
                    [DOUBLE PRECISION] => 2
                    [FIXED] => 2
                    [FLOAT] => 2
                )

            [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo
            [_config:protected] => Array
                (
                    [dbname] => backupservice
                    [username] => backup
                    [password] => ***********
                    [host] => ***********
                    [charset] => utf8
                    [persistent] => 
                    [options] => Array
                        (
                            [caseFolding] => 0
                            [autoQuoteIdentifiers] => 1
                        )

                    [driver_options] => Array
                        (
                            [1002] => SET NAMES 'utf8'
                        )

                )

            [_fetchMode:protected] => 2
            [_profiler:protected] => Zend_Db_Profiler Object
                (
                    [_queryProfiles:protected] => Array
                        (
                        )

                    [_enabled:protected] => 
                    [_filterElapsedSecs:protected] => 
                    [_filterTypes:protected] => 
                )

            [_defaultProfilerClass:protected] => Zend_Db_Profiler
            [_connection:protected] => PDO Object
                (
                )

            [_caseFolding:protected] => 0
            [_autoQuoteIdentifiers:protected] => 1
            [_allowSerialization:protected] => 1
            [_autoReconnectOnUnserialize:protected] => 
        )

    [_attribute:protected] => Array
        (
        )

    [_bindColumn:protected] => Array
        (
        )

    [_bindParam:protected] => Array
        (
        )

    [_sqlSplit:protected] => Array
        (
            [0] => SELECT `jobs`.* FROM `jobs` WHERE (jobid = ) ORDER BY `jobid` ASC LIMIT 1
        )

    [_sqlParam:protected] => Array
        (
            [0] => SELECT `jobs`.* FROM `jobs` WHERE (jobid = ) ORDER BY `jobid` ASC LIMIT 1
        )

    [_queryId:protected] => 
)

rara UPDATE `jobs` SET `status` = ?, `finish` = ?, `joblog` = ? WHERE (jobid = '4')

Array
(
    [0] => finished
    [1] => 2011-05-10 14:15:51
    [2] => 
rara
)

Zend_Db_Statement_Pdo Object
(
    [_fetchMode:protected] => 2
    [_stmt:protected] => PDOStatement Object
        (
            [queryString] => UPDATE `jobs` SET `status` = ?, `finish` = ?, `joblog` = ? WHERE (jobid = '4')
        )

    [_adapter:protected] => Zend_Db_Adapter_Pdo_Mysql Object
        (
            [_pdoType:protected] => mysql
            [_numericDataTypes:protected] => Array
                (
                    [0] => 0
                    [1] => 1
                    [2] => 2
                    [INT] => 0
                    [INTEGER] => 0
                    [MEDIUMINT] => 0
                    [SMALLINT] => 0
                    [TINYINT] => 0
                    [BIGINT] => 1
                    [SERIAL] => 1
                    [DEC] => 2
                    [DECIMAL] => 2
                    [DOUBLE] => 2
                    [DOUBLE PRECISION] => 2
                    [FIXED] => 2
                    [FLOAT] => 2
                )

            [_defaultStmtClass:protected] => Zend_Db_Statement_Pdo
            [_config:protected] => Array
                (
                    [dbname] => backupservice
                    [username] => backup
                    [password] => ***********
                    [host] => ***************
                    [charset] => utf8
                    [persistent] => 
                    [options] => Array
                        (
                            [caseFolding] => 0
                            [autoQuoteIdentifiers] => 1
                        )

                    [driver_options] => Array
                        (
                            [1002] => SET NAMES 'utf8'
                        )

                )

            [_fetchMode:protected] => 2
            [_profiler:protected] => Zend_Db_Profiler Object
                (
                    [_queryProfiles:protected] => Array
                        (
                        )

                    [_enabled:protected] => 
                    [_filterElapsedSecs:protected] => 
                    [_filterTypes:protected] => 
                )

            [_defaultProfilerClass:protected] => Zend_Db_Profiler
            [_connection:protected] => PDO Object
                (
                )

            [_caseFolding:protected] => 0
            [_autoQuoteIdentifiers:protected] => 1
            [_allowSerialization:protected] => 1
            [_autoReconnectOnUnserialize:protected] => 
        )

    [_attribute:protected] => Array
        (
        )

    [_bindColumn:protected] => Array
        (
        )

    [_bindParam:protected] => Array
        (
        )

    [_sqlSplit:protected] => Array
        (
            [0] => UPDATE `jobs` SET `status` = 
            [1] => ?
            [2] => , `finish` = 
            [3] => ?
            [4] => , `joblog` = 
            [5] => ?
            [6] =>  WHERE (jobid = )
        )

    [_sqlParam:protected] => Array
        (
            [0] => UPDATE `jobs` SET `status` = 
            [1] => ?
            [2] => , `finish` = 
            [3] => ?
            [4] => , `joblog` = 
            [5] => ?
            [6] =>  WHERE (jobid = )
        )

    [_queryId:protected] => 
)

Can anyone tell me what i am doing wrong here?

Comments

No comments to display