O'Reilly logo

PHP 5 CMS Framework Development by Martin Brampton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exploring PHP—arrays and SQL

The array handling functions of PHP are exceptionally powerful, and well worth exploring. In this section, we explore some widely used techniques that are helpful in building SQL statements.

One situation that is very common is the need for a SQL statement that will have a variable number of WHERE clauses, depending on the particular circumstances. For simplicity, suppose that all the conditions have to be joined together using AND.

Of course, we could write a conditional statement each time another item is to be added to the SQL. But it would be clumsy because the logic would be different for the first condition actually required, which needs to be preceded by WHERE and the other cases, which need to be preceded ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required