Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
    
same problem... no solution found... –  Simone Nigro Jan 18 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 –  Tzook Bar Noy Feb 4 at 10:33
2  
I'll install postgres and check the code and commit a fix –  Tzook Bar Noy Feb 4 at 10:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.