2
CREATE TYPE mpaa_rating AS ENUM (
    'G',
    'PG',
    'PG-13'
);

CREATE TABLE film (
    film_id integer DEFAULT nextval('film_film_id_seq'::regclass) NOT NULL,
    rating mpaa_rating DEFAULT 'G'::mpaa_rating
);

I've tried the following:

  1. pg_insert($dbconn, "film", new array("rating" => "PG"));
  2. pg_insert($dbconn, "film", new array("rating" => "'PG'::mpaa_rating"));
  3. pg_insert($dbconn, "film", new array("rating" => "PG::mpaa_rating"));

I get the error: unknown or system data type

1
  • Good call on use of PG's enums. Commented Jul 1, 2010 at 3:48

1 Answer 1

1
pg_query($dbconn, "insert into film(rating) values('PG');");

pg_insert is experimental and has several shortcomings.

Sign up to request clarification or add additional context in comments.

1 Comment

Or even better, use pg_query_params().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.