Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DboOdbc::execute($sql, $options = array()) gives random errors without a real cause #66

Open
ghost opened this issue Oct 11, 2013 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented Oct 11, 2013

Created by dalpo, 19th Mar 2010. (originally Lighthouse ticket #18):


I encountered this problem trying to develop a MS Access datasource via odbc.
This is the problem:

DboOdbc::execute is inherited by DboSource::execute method...

    function execute($sql, $options = array()) {
        $defaults = array('stats' => true, 'log' => $this->fullDebug);
        $options = array_merge($defaults, $options);

        $t = getMicrotime();
        $this->_result = $this->_execute($sql);
        if ($options['stats']) {
            $this->took = round((getMicrotime() - $t) * 1000, 0);
            $this->affected = $this->lastAffected();
            $this->error = $this->lastError(); // <<<<  TAKE A LOOK HERE
            $this->numRows = $this->lastNumRows();
        }

        if ($options['log']) {
            $this->logQuery($sql);
        }

        if ($this->error) {
            $this->showQuery($sql);
            return false;
        }
        return $this->_result;
    }

Whose method invokes the $this->lastError(); even if there isn't errors.
So this is a problem because the odbc error reporting functions odbc_error and odbc_errormsg should be invoked only when odbc_exec() return false
Otherwise, in my case it gives random errors..

From php.net:

This function returns meaningful value only if last odbc query failed (i.e. odbc_exec() returned FALSE).

References:

http://php.net/manual/en/function.odbc-error.php

http://www.php.net/manual/en/function.odbc-errormsg.php

I hope to be helpful and sorry for my bad English ^_^'

bye

@AD7six AD7six added the odbc label Feb 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant