Reading boolean correctly from Postgres by PHP

后端 未结 4 1142
野性不改
野性不改 2021-02-14 14:58

The main problem of this thread is moved to here about boolean datatype in PHP / Postgres.

The problem is the conversion of t and f to

4条回答
  •  温柔的废话
    2021-02-14 15:31

    Select boolean field from postgre as ::int and in php cast to bool.

     "SELECT a_moderator::int 
            FROM users
            WHERE email = $1;"
    

    $isModerator = (bool)$row['a_moderator'];

提交回复
热议问题