Search code examples
phppostgresqlnull

how to insert null in postgres with php


I'm trying to insert null into a postgres database with php. Say I have this:

<?php
$sql = <<<EOT
insert into
    t1
(c1, c2)
values
($param, 'test')
EOT;
?>

I tried setting $param to:

$param = null;
$param = '\N';

and in each case I got this error:

Native message: ERROR:  syntax error at or near ","

What do I need to set it to?


Solution

  • $param = 'null';
    

    it should work.