我使用Codeigniter框架和PostgreSQL数据库开发了一个应用程序。我不时收到这个错误:
psql:FATAL:剩余的连接插槽是为非复制超级用户连接保留的
我已经读过Codeigniter管理连接,必要时关闭它。但是,
php.ini
设置为pgsql.allow_persistent
变量值为“off”。pcconnect
变量配置为“false”
我的CodeIgniter应用程序中的database.php
。我还应该怎么做?错误仍然存在。
以下是database.php配置。出于隐私和安全原因,在示例中修改了变量hostname,username和password:
$db['default'] = array(
'dsn' => '',
'hostname' => 'my_host',
'username' => 'my_user',
'password' => 'my_password',
'database' => 'my_database_name',
'dbdriver' => 'postgre',
'port' => '5432',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
这是我的数据库结构:
CREATE TABLE anuncio_imovel (
id integer NOT NULL,
imobiliaria integer NOT NULL,
data date DEFAULT ('now'::text)::date NOT NULL,
titulo character varying(250) NOT NULL,
tipo_negocio character varying(250) NOT NULL,
logradouro character varying(250),
numero character varying(15),
bairro character varying(250) NOT NULL,
cidade character varying(250) NOT NULL,
complemento character varying(250),
estado character(2) NOT NULL,
descricao text,
imagem character varying(250),
comodos integer DEFAULT 0,
valor double precision DEFAULT 0.0,
link character varying(250) DEFAULT ''::character varying
);
CREATE SEQUENCE anuncio_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE anuncio_id_seq OWNED BY anuncio_imovel.id;
CREATE TABLE edicao (
id integer NOT NULL,
ano character varying(4) NOT NULL,
mes character varying(15) NOT NULL,
volume character varying(10),
ativa boolean DEFAULT false,
numero character varying(5) DEFAULT 1 NOT NULL
);
CREATE SEQUENCE edicao_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE edicao_id_seq OWNED BY edicao.id;
CREATE TABLE galeria_imovel (
id integer NOT NULL,
foto character varying(250) NOT NULL,
anuncio_imovel integer NOT NULL
);
CREATE SEQUENCE galeria_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE galeria_id_seq OWNED BY galeria_imovel.id;
CREATE TABLE galeria_noticia (
id integer NOT NULL,
foto character varying(250) NOT NULL,
noticia integer NOT NULL,
link character varying(250),
legenda text
);
CREATE SEQUENCE galeria_noticia_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE galeria_noticia_id_seq OWNED BY galeria_noticia.id;
CREATE TABLE imobiliaria (
id integer NOT NULL,
nome_fantasia character varying(250) NOT NULL,
logradouro character varying(250),
numero character varying(15),
bairro character varying(250),
cidade character varying(250),
estado character(2),
telefone character varying(15),
telefone2 character varying(15),
email character varying(250),
logo character varying(250),
site character varying(250)
);
CREATE SEQUENCE imobiliaria_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE imobiliaria_id_seq OWNED BY imobiliaria.id;
CREATE SEQUENCE imovel_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE imovel_id_seq OWNED BY anuncio_imovel.id;
CREATE TABLE noticia (
id integer NOT NULL,
titulo character varying(250) NOT NULL,
texto text NOT NULL,
imagem character varying(250),
tipo character varying(250) NOT NULL,
data date DEFAULT ('now'::text)::date,
link character varying(250),
rotulo_link character varying(250),
imagem2 character varying(250),
video character varying(250),
autor character varying(250),
nivel integer DEFAULT 13
);
CREATE SEQUENCE noticia_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE noticia_id_seq OWNED BY noticia.id;
CREATE TABLE pagina (
id integer NOT NULL,
imagem text,
edicao integer NOT NULL,
numero integer DEFAULT 0 NOT NULL,
link character varying(250),
link2 character varying(250),
link3 character varying(250),
link4 character varying(250),
rotulo_link character varying(250),
rotulo_link2 character varying(250),
rotulo_link3 character varying(250),
rotulo_link4 character varying(250)
);
CREATE SEQUENCE pagina_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE pagina_id_seq OWNED BY pagina.id;
CREATE TABLE propaganda (
id integer NOT NULL,
imagem character varying(250) NOT NULL,
link character varying(250) NOT NULL,
posicao character varying(150)
);
CREATE SEQUENCE propaganda_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE propaganda_id_seq OWNED BY propaganda.id;
CREATE TABLE usuario (
id integer NOT NULL,
nome character varying(150) NOT NULL,
email character varying(150) NOT NULL,
senha character varying(150) NOT NULL,
nome_grupo character varying(150) DEFAULT 'usuarios'::character varying NOT NULL,
visivel_home boolean DEFAULT false,
foto character varying(250)
);
CREATE SEQUENCE usuario_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE usuario_id_seq OWNED BY usuario.id;
CREATE TABLE video (
id integer NOT NULL,
url character varying(250) NOT NULL,
titulo character varying(250) NOT NULL,
data date DEFAULT ('now'::text)::date
);
CREATE SEQUENCE video_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE video_id_seq OWNED BY video.id;
CREATE TABLE visita (
qtd integer NOT NULL
);
ALTER TABLE ONLY anuncio_imovel ALTER COLUMN id SET DEFAULT nextval('anuncio_id_seq'::regclass);
ALTER TABLE ONLY edicao ALTER COLUMN id SET DEFAULT nextval('edicao_id_seq'::regclass);
ALTER TABLE ONLY galeria_imovel ALTER COLUMN id SET DEFAULT nextval('galeria_id_seq'::regclass);
ALTER TABLE ONLY galeria_noticia ALTER COLUMN id SET DEFAULT nextval('galeria_noticia_id_seq'::regclass);
ALTER TABLE ONLY imobiliaria ALTER COLUMN id SET DEFAULT nextval('imobiliaria_id_seq'::regclass);
ALTER TABLE ONLY noticia ALTER COLUMN id SET DEFAULT nextval('noticia_id_seq'::regclass);
ALTER TABLE ONLY pagina ALTER COLUMN id SET DEFAULT nextval('pagina_id_seq'::regclass);
ALTER TABLE ONLY propaganda ALTER COLUMN id SET DEFAULT nextval('propaganda_id_seq'::regclass);
ALTER TABLE ONLY usuario ALTER COLUMN id SET DEFAULT nextval('usuario_id_seq'::regclass);
ALTER TABLE ONLY video ALTER COLUMN id SET DEFAULT nextval('video_id_seq'::regclass);
ALTER TABLE ONLY anuncio_imovel
ADD CONSTRAINT anuncio_imovel_pkey PRIMARY KEY (id);
ALTER TABLE ONLY noticia
ADD CONSTRAINT coluna_pkey PRIMARY KEY (id);
ALTER TABLE ONLY edicao
ADD CONSTRAINT edicao_key PRIMARY KEY (id);
ALTER TABLE ONLY galeria_imovel
ADD CONSTRAINT galeria_imovel_pkey PRIMARY KEY (id);
ALTER TABLE ONLY galeria_noticia
ADD CONSTRAINT galeria_noticia_pkey PRIMARY KEY (id);
ALTER TABLE ONLY imobiliaria
ADD CONSTRAINT imobiliaria_pkey PRIMARY KEY (id);
ALTER TABLE ONLY pagina
ADD CONSTRAINT pagina_pkey PRIMARY KEY (id);
ALTER TABLE ONLY propaganda
ADD CONSTRAINT propaganda_pkey PRIMARY KEY (id);
ALTER TABLE ONLY visita
ADD CONSTRAINT qtd_constraint PRIMARY KEY (qtd);
ALTER TABLE ONLY usuario
ADD CONSTRAINT usuario_email_key UNIQUE (email);
ALTER TABLE ONLY usuario
ADD CONSTRAINT usuario_pkey PRIMARY KEY (id);
ALTER TABLE ONLY video
ADD CONSTRAINT video_pkey PRIMARY KEY (id);
ALTER TABLE ONLY visita
ADD CONSTRAINT visita_qtd_key UNIQUE (qtd);
ALTER TABLE ONLY anuncio_imovel
ADD CONSTRAINT anuncio_imovel_imobiliaria_fkey FOREIGN KEY (imobiliaria) REFERENCES imobiliaria(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY galeria_imovel
ADD CONSTRAINT galeria_imovel_anuncio_imovel_fkey FOREIGN KEY (anuncio_imovel) REFERENCES anuncio_imovel(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY galeria_noticia
ADD CONSTRAINT galeria_noticia_noticia_fkey FOREIGN KEY (noticia) REFERENCES noticia(id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY pagina
ADD CONSTRAINT pagina_edicao_fkey FOREIGN KEY (edicao) REFERENCES edicao(id) ON UPDATE CASCADE ON DELETE CASCADE;