Ú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
- Samsung Galaxy Watch 4 Classic 42mm, GPS, 1 Év Garanciával
- Új Honor X7d 128GB, Kártyafüggetlen, 1 Év Garanciával
- BESZÁMÍTÁS! Gigabyte B650M R5 7600 16GB DDR5 512GB SSD RX 9070 XT 16GB NZXT H7 Flow fehér 750W
- Samsung Galaxy Tab S9 FE 256GB, Wi-Fi, 1 Év Garanciával
- Asus TUF B760-Plus Wifi (apró hibával)
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
