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

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

 



On Tue, Mar 10, 2009 at 05:44:31AM +0100, Thilo Klein wrote:

> Dear readers,
>
>    I am new to relational DB but not to MySQL & PHP in general. I
> created a RDB using Powerdesigner. 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.

Assuming you want to use straight PHP (as opposed to an
object-relational mapping framework), you have several choices. You can
use the native PHP mysql functions to access the tables. Or you can use
PHP's PDO classes (or similar). Both are documented at php.net (and very
well, I might add).

Your ER diagram is a visual representation of various "CREATE TABLE"
statements in SQL. Using straight PHP, you'll need to learn to use the
SQL language to make queries and changes to the tables. It is relatively
simple to learn, but essential unless you want to use some odd
framework, as I mentioned before. SQL queries would look something like
this:

$result = mysql_query("SELECT name, address FROM people WHERE country =
'Germany'", $connection_info);

Then, you would do something like:

$person = mysql_fetch_array($result)

And $person would look like this:

$person = array('name' => 'Helmut Schmidt', 'address' => '123 Anystrasse');

I want to stress that PHP is *not* a *visual* language. You have to sit
down with an editor and write it. Very unlike programs which allow you
to design tables using visual means.

Hope that helps.

Paul

-- 
Paul M. Foster

-- 
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