Új hozzászólás Aktív témák
-
lanszelot
addikt
válasz
martonx
#6019
üzenetére
Köszönöm szépen.
Valamit nem jó; értek, mert eddig jutottam, de nem jó:
//Create another table - Main table for shared ID -This table share ID with supplier_groups
$sql = "CREATE TABLE IF NOT EXISTS suppliers (
supplier_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
supplier_name TEXT NOT NULL,
group_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
FOREIGN KEY (group_id)
REFERENCES supplier_groups (group_id))";
try {
$connection->exec($sql);
echo "Table suppliers created successfully";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
//Create another table - Secondary table with shared ID - This table got ID from suppliers table
$sql = "CREATE TABLE IF NOT EXISTS supplier_groups (
group_id integer PRIMARY KEY,
group_name text NOT NULL)";
try {
$connection->exec($sql);
echo "Table supplier_groups created successfully";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
// Create (Insert) Data. SQL query to insert data into the "suppliers" table
$sql = "INSERT INTO suppliers (supplier_name) VALUES ('Obi van Kenobi')";
$sql2 = "INSERT INTO supplier_groups (group_name) VALUES ('jedi')";
try {
$connection->exec($sql);
$connection->exec($sql2);
echo "Data inserted successfully";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
Új hozzászólás Aktív témák
- Apple iPhone 13 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- ÁRGARANCIA!Épített KomPhone i5 12400F 16/32/64GB RAM RTX 5060 Ti 8GB GAMER PC termékbeszámítással
- iKing.hu Apple iPhone 15 Pro 128GB Natural Titanium használt, karcmentes 92% akku 6 hónap garancia
- Keresünk Galaxy S21/S21+/S21 Ultra/S21Fe
- Honor Pad X8 / 4/64GB / Wi-Fi / 12 Hó Garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest

