PHP - Advanced Tutorial

4 downloads 22255 Views 352KB Size Report
Dec 6, 2002 ... PHP - Advanced Tutorial. Gulev. December 6, 2002. Veracruz, Mexico. Rasmus Lerdorf http://lerdorf.com/veracruz.pdf ...
PHP - Advanced Tutorial Gulev December 6, 2002. Veracruz, Mexico Rasmus Lerdorf http://lerdorf.com/veracruz.pdf

Slide 1/64

o o o o o o o o o o o

Agenda

PHP-MySQL Cookie Handling Dynamic Images PDF Flash Sessions Security Tips & Tricks Optimization Latest Developments Future

-2-

December 6, 2002

Slide 2/64

Setup

December 6, 2002

Check your PHP Setup for MySQL support

If not enabled Very rare since a MySQL client library is distributed with PHP and built into PHP by default. However, it is possible to build PHP without MySQL support. Some possible fixes: apt-get install php-mysql rpm -Uvh php-mysql-4.2.2-1.i386.rpm

./configure --with-mysql=shared,/usr cp modules/mysql.so /usr/local/lib/php extension_dir=/usr/local/lib/php extension=mysql.so

-3-

Slide 3/64

December 6, 2002

Sanity Check

Make sure MySQL is running prompt:~> mysqlshow +-----------+ | Databases | +-----------+ | mysql | | test | +-----------+

Or with the latest PHP

Output: Uptime: 6717 Threads: 1 Questions: 1 Slow queries: 0 Open tables: 0 Queries per second avg: 0.000

-4-

Opens: 6

Flush tables: 1

Slide 4/64

Connecting to MySQL

The simple connection

Output: Resource id #28

Other variations

-5-

December 6, 2002

Slide 5/64

Persistent Connections

The simple connection

Output: Resource id #31

Caveats o Watch out for multi-credential connections o Make sure you match up max_connections and MaxClients

-6-

December 6, 2002

Slide 6/64

Creating a Database

Create a DB

Output: Database foo created

Create a Table