Postgres pg_prepare , pg_execute and INSERT problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pentium10
Forum Newbie
Posts: 1
Joined: Sun Oct 19, 2008 12:53 pm

Postgres pg_prepare , pg_execute and INSERT problem

Post by pentium10 »

Hello,

I have a rule setup on PostgreSQL to return a column after insert.
[sql] CREATE RULE get_projectkey_on_insert AS ON INSERT TO projects DO SELECT currval(('projects_id_seq'::text)::regclass) AS id;[/sql]

I use pg_prepare, and pg_execute

Code: Select all

 
$sql="insert into " . $this->TableName. " (username,companycode,projectname) values ($1,$2,$3)";
$this->result=@pg_prepare("projects_insert",$sql)  or die(pg_errormessage());
 

Code: Select all

 
$this->result=@pg_execute("projects_insert",
    array(
        $GLOBALS["username"],
        $GLOBALS["companycode"],
        ''
        )
    ) or die(pg_errormessage());
 
My problem is that pg_execute result seams empty and I cannot get the expected value the ID of the projects table.
Can you help?

Regards,
Pentium10
Post Reply