Free Advanced PHP Tutorial
Sample of the pdf document :
Sanity Check:
Make sure MySQL is running
prompt:~> mysqlshow
+-----------+
| Databases |
+-----------+
| mysql |
| test |
+-----------+
Or with the latest PHP
<? echo mysql_stat() ?>
Output:
Uptime: 6717 Threads: 1 Questions: 1 Slow queries: 0 Opens: 6 Flush tables: 1
Open tables: 0 Queries per second avg: 0.000
Connecting to MySQL:
The simple connection
<?
$conn = mysql_connect('localhost');
echo $conn;
?>
Output:
Resource id #28
Other variations
<?
mysql_connect('db.domain.com:33306','rasmus','foobar');
mysql_connect('localhost:/tmp/mysql.sock');
mysql_connect('localhost','rasmus','foobar',
true,MYSQL_CLIENT_SSL|MYSQL_CLIENT_COMPRESS);
Persistent Connections:
The simple connection
<?
$conn = mysql_pconnect('localhost');
echo $conn;
?>
Output:
Resource id #31
Caveats
o Watch out for multi-credential connections
o Make sure you match up max_connections and MaxClients
Click here for Download PDF / FREE
0 commentaires: