xhprof icon indicating copy to clipboard operation
xhprof copied to clipboard

Error while using sqlite database

Open sricharanchandrasekar opened this issue 11 years ago • 6 comments

Encountered the following errors when used sqlite database. I used the following configuration in the config:

$_xhprof['dbtype'] = 'sqlite:/path_to_folder/db_name'; $_xhprof['dbhost'] = ''; $_xhprof['dbuser'] = ''; $_xhprof['dbpass'] = ''; $_xhprof['dbname'] = 'db_name'; $_xhprof['dbadapter'] = 'Pdo';

There is no username and password for the sqlite.

The following error was returned:

Call to a member function fetch() on a non-object in xhprof_lib/utils/Db/Pdo.php

sricharanchandrasekar avatar Aug 28 '14 07:08 sricharanchandrasekar

I guess there is line number too in that error message that you missed to report? While you're at it can you please link to corresponding code line on GitHub?

aik099 avatar Aug 28 '14 07:08 aik099

Actually tried modifying the Pdo.php as

public function connect()
    {
        if ($this->config['dbtype'] == 'sqlite')
        {
                $connectionString = $this->config['dbtype'] .':'.$this->config['dbname'];
        }
        else
        {
                $connectionString = $this->config['dbtype'] . ':host=' . $this->config['dbhost'] . ';dbname=' . $this->config['dbname'];
        }

So that when the sqlite is required, there isn't necessity to provide the username and password. Also, the number that was linked was the return statement in the below snippet

public static function getNextAssoc($resultSet)
    {
        return $resultSet->fetch();
    }

Vidzz avatar Aug 28 '14 07:08 Vidzz

@Vidzz can you please use fenced blocks (see https://help.github.com/articles/github-flavored-markdown#syntax-highlighting) to enable code highlighting in your comments?

aik099 avatar Aug 28 '14 07:08 aik099

I see you've made a fix, please submit it in PR (pull request) format.

aik099 avatar Aug 28 '14 07:08 aik099

@aik099 Sorry for missing the line number. The error occurred in the module getNextAssoc of the xhprof_lib/utils/Db/Pdo.php file as mentioned by @Vidzz .

sricharanchandrasekar avatar Aug 28 '14 09:08 sricharanchandrasekar

@Vidzz can you please send a PR with a fix?

aik099 avatar Jun 07 '15 11:06 aik099