开发者

Inserting a custom Postgres datatype with PHP

开发者 https://www.devze.com 2023-01-05 12:39 出处:网络
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,
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_inser开发者_开发百科t($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


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

pg_insert is experimental and has several shortcomings.

0

精彩评论

暂无评论...
验证码 换一张
取 消