Re: [PHP & MySQL] Introduction to using relational databases

From: Date: Tue, 10 Mar 2009 05:38:12 +0000
Subject: Re: [PHP & MySQL] Introduction to using relational databases
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-289752@lists.php.net to get a copy of this message
Thilo Klein wrote:
Dear readers, I am new to relational DB but not to MySQL & PHP in general. I created a RDB using Struggling with the program's complexity I managed to create a set of databases being interconnected via (foreign) keys. What I want to know is how to use this database via php. How does my ER-Diagram come into play? In other words I want to know more about a general approach to using relational databases via php. Regards from .de Thilo PS: If you speak german, answer in german. Appreciate it.
well you export the db you designed into ansi sql and use the cmdline mysql client to create a db with it... this guide http://www.databasejournal.com/features/mysql/article.php/1469211/Using-a-MySQL-database-with-PHP.htm seems ok on the first look.. from php you access the db like this... <?php $username = "pee_wee"; $password = "let_me_in"; $hostname = "localhost"; $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to mysql"); print "connected to mysql<br>"; $selected = mysql_select_db("first_test",$dbh) or die("Could not select first_test"); if (mysql_query("insert into people values('5','Hazel','Burger')")) { print "successfully inserted record"; } else { print "Failed to insert record"; } mysql_close($dbh); ?> Dirk

« previous php.general (#289752) next »