Jump to content

Insert em tabela hereditária


ricardoaux

Recommended Posts

Boas

Tenho as seguintes tabelas:

create table "muchatcha"."MESSAGE"
(
ID_MESSAGE		 serial UNIQUE				 not null,
ID_USER			 serial					 not null,
FIL_ID_MESSAGE	 integer					 null,
CONTENT			 varchar(500)				 null,
constraint PK_MESSAGE primary key (ID_MESSAGE)
);
create table "muchatcha".CHAT_MESSAGE
(
ID_MESSAGE		 serial UNIQUE			 not null,
ID_ROOM			 serial						 not null,
ID_USER			 serial					 not null,
CONTENT			 varchar(500)				 null,
constraint PK_CHAT_MESSAGE primary key (ID_MESSAGE)
);

create table "muchatcha".PRIVATE_MESSAGE
(
ID_MESSAGE		 serial UNIQUE				 not null,
ID_USER			 serial					 not null,
USE_ID_USER		 serial					 not null,
CONTENT			 varchar(500)				 null,
SENT_DATE		 timestamp					 null,
RECEIVED_DATE	 timestamp					 null,
constraint PK_PRIVATE_MESSAGE primary key (ID_MESSAGE)
);

Como adiciono algo na tabela private_message???

Uso o Postgres

Cumps

Edited by Rechousa
Formatação de código
Link to comment
Share on other sites

pg_query("BEGIN") or die("Transaction commit failed\n");
pg_query($dbh, "INSERT INTO \"muchatcha\".\"MESSAGE\" (id_user, content)"."VALUES('$userM_Id', '$mensM')");
$result = pg_query($dbh, "SELECT MAX(id_message) FROM \"muchatcha\".\"MESSAGE\"");
$row = pg_fetch_row($result);
$idM = $row[0];
echo $idM;
pg_query($dbh, "INSERT INTO \"muchatcha\".\"private_messsage\" (id_message, id_user, use_id_user, content, sent_date, received_date)"."VALUES('$idM', '$userM_Id', '$userID', '$mensM', '$dateS', '$dateR')");
pg_query("COMMIT") or die("Transaction commit failed\n");
Edited by Rechousa
Formatação de código
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.