[ Thanks to Adam
Berlinsky-Schine for this link. ]
“There are many articles that will tell you how to connect to a
database with PHP, perform simple queries and work with the
results. This article will not cover those basics. The purpose
of this article is to cover some of the less obvious things that
can be done when working with SQL, and how to utilize them with
PHP. SQL is a very powerful language and can do many things if
used correctly and efficiently.”
“I will be using MySQL as the database for this article, simply
because more beginning PHP programmers use it than any other
database. The first database I used with PHP was PostgreSQL, and
most if not all of these examples will work with it simply by
calling the equivalent PostgreSQL functions. For a working example
of PostgreSQL functions, see the Assembly Coder’s Zenith website.
The footer on every page of the main site has a link to view the
source code of the page (shameless plug, I know).”
“Good coding practices and standards will save you many hours in
both development time and in debugging. This cannot be emphasized
enough. Many times while programming I will end up writing the same
few lines of code over and over. When I realize this, I will write
a function to handle it and change all the code into function
calls. Sure, it takes a few minutes, but then the next time the
code is needed, a mere function call is all that it takes. And the
code is easier to read. If you find yourself doing a lot of
copy/paste coding, consider using a function call. When you are
done with a project you will likely have many functions written.
You will be able to move many of these into a shared include file.
Instead of writing new code on your next project, you will be able
to use the already functions immediately. Another reason using a
function is important is that it allows you to do more error
checking than might normally be done.”