This chapter discusses the basic usage of CpmFetch and how you can get the most out of it.
CpmFetch is an object. For those of you who don't understand what an object is, think of it as a seperate program that you can start and access from your php pages. For those of you who do know what an object is, don't bother trying to correct me on the over simplified explaination. (grin)
To start CpmFetch up you need to tell your PHP page where it can find the cpmfetch.php program. You do this with the php require_once directive. You can also use require or include, but require_once is a good habit to get into. After you do that, you need to instruct PHP to start the object and give it a name to call it by.
Example 5.1. Starting CpmFetch
<?php require_once "./cpmfetch/cpmfetch.php"; $objCpm = new cpmfetch("/photos"); ?>
In the example above, we decided to call our object $objCpm. You can call it whatever you want mostly as long as its a valid php variable. From now on, any time we want to talk to our cpmfetch program, we will use $objCpm.
You will notice that the cpmfetch program takes one parameter to start. This is your partial URL to you Coppermine Gallery. This saves you the trouble of entering all your database information again. Many of the other thing you will tell CpmFetch to do also take parameters. We will talk about that later. The partial URL is the part of your full URL to get to coppermine, without the domain name on it. So for example, to get to my photo gallery is http://www.fistfullofcode.com/photos - then my partial url is /photos
When you want to tell CpmFetch something you call one of many functions and pass it some information. Details on all of the function is covered in the functions chapter.
After amazing friends and family with the incredible web sites you have all of the sudden, you will want to stop CpmFetch. This allows it to close its connection to the database. While PHP will close connections for you automatically at the end, this is another good habit.
In the above listing, we are calling our cpmfetch object (program) and telling it (via the ->) to run its close() function. You can place the start at the top of your page and the close at the bottom. This makes it easy to find later, and you can do things all over your web page without having to start and stop.