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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux