Postgres pg_prepare , pg_execute and INSERT problem
Posted: Sun Oct 19, 2008 12:55 pm
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
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
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());
Can you help?
Regards,
Pentium10