I have a table in PostgreSQL that was created using this statement:
CREATE TABLE cms_page
(
id serial NOT NULL,
parent_id int4 NOT NULL DEFAULT 0,
title varchar(255) NOT NULL,
rank int4 NOT NULL DEFAULT 1,
active boolean DEFAULT true,
PRIMARY KEY (id)
);
-- create special root node
INSERT INTO cms_page VALUES (0,0,'Home',1,true);
-- set up integrity keys
ALTER TABLE cms_page
ADD FOREIGN KEY (parent_id)
REFERENCES cms_page (id)
ON UPDATE CASCADE
ON DELETE CASCADE;
CREATE UNIQUE INDEX cms_page_u1
ON cms_page (parent_id, title);
CREATE UNIQUE INDEX cms_page_u2
ON cms_page (parent_id, rank);
Then I have a query as simple as this:
INSERT INTO cms_page (parent_id, title, rank) VALUES (0, 'Test 1', 1);
Which fails with: "DB Error: Unknown Error"
However, if I execute this exact same query through the psql terminal, it works fine. Can anyone offer a suggestion? Here's the PHP code for the page:
$db_connection = DB::connect($db_hosttype."://".$db_username.":".$db_password."@".$db_hostname."/".$db_database);
if (DB::isError($db_connection)) die($db_connection->getMessage());
$sql1 = "INSERT INTO cms_page (parent_id, title, rank) VALUES (0,'test',6)";
$q_doadd = $db_connection->query($sql1);
if(DB::isError($q_doadd)) die($q_doadd->getMessage());
Thanks very much... I'm pulling my hair out over this one and totally baffled!
-Cliff