2

I have a site, that uses laravel 4.2 (stable) with Eloquent. I am also using this User messaging system. I wanted to switch database from mysql to postgres. On mysql, everything worked fine. I changed configs to postgres, run all migrations and everything seemed to work, except parts, that use the messaging library, which gave this error:

Undefined property: stdClass::$numOfUnread

The first bit of info, I request from that library is number of unread messages for logged in user. After seeding, there are no messages.

I read about this error and there were couple of reasons, usually error in dev version of Laravel. In my case everything apart from that library works fine and this library also worked fine on mysql.

My config is:

'fetch' => PDO::FETCH_CLASS,
'default' => 'pgsql',
'pgsql' => array(
  'driver'   => 'pgsql',
  'host'     => 'localhost',
  'database' => '****',
  'username' => '****',
  'password' => '****',
  'charset'  => 'utf8',
  'prefix'   => '',
        'schema'   => 'public',
),

I also tried to narrow the error in the library and I've found it in this file

public function getNumOfUnreadMsgs($user_id) {
    $results = $this->db->select(
    '
    SELECT COUNT(mst.id) as "numOfUnread"
    FROM '.$this->tablePrefix.'messages_status mst
    WHERE mst.user_id=?
    AND mst.status=?
    ',
    [$user_id, self::UNREAD]
    );
    return (isset($results[0]))? $results[0]->numOfUnread : 0;
}

It looks like mysql returns:

array(1) { [0]=> object(stdClass)#881 (1) { ["numOfUnread"]=> int(1) } }

and postgres returns:

array(1) { [0]=> object(stdClass)#881 (1) { ["numofunread"]=> int(1) } }

Can I somehow force postgres to return field names with capital letters?

3
  • same problem... no solution found... Commented Jan 18, 2015 at 11:18
  • 2
    Hellp tkowal and @Simone Nigro, I wrote the package and I'll take a look at that, I already had an issue with postgres and it was solved, so let me take a look Commented Feb 4, 2015 at 10:33
  • 2
    I'll install postgres and check the code and commit a fix Commented Feb 4, 2015 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.