Ed D
Ed D

Reputation: 23

Inserting a custom Postgres datatype with PHP

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

Upvotes: 2

Views: 854

Answers (1)

Artefacto
Artefacto

Reputation: 97835

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

pg_insert is experimental and has several shortcomings.

Upvotes: 1

Related Questions