| Prev | Next |
Most important is to understand how it all works. POT provides classes to abstract many OTServ resources. Main class of toolkit is named POT. Many resource handlers are assigned to POT instance.
POT class implements singleton pattern. It means you should use only one instance of this class everywhere. Thanks to PHP5 and methods access definers, it's constructor was restricted to private so you won't even be able to create more instances. This might seem quite odd for you - you won't create object directly. To get POT class instance you have to use getInstance() method. In next section you will see example how to call this method.
What is it for? POT class defines entire enviroment for working with OTServ. In single instance you define all resources needed to work with given server. And now imagine you would want to move that enviroment into another scope, for example into function. Since singleton is a static instance, there is no problem with that. You just fetch the very same enviroment every time you call POT::getInstance().
Probably the most important part of this toolkit is database operations part. To execute any operations on database you first have to connect. POT supports 4 SQL drivers: MySQL, SQLite, PgSQL and ODBC. Each of those drivers has different connection parameters list so look into theirs documentation for details. To connect with database you use connect() method.
To execute particular operations you will use objects and it's usage will be described in further parts of this tutorial.
As a core for database handle PDO instance is used. You can get pure connection handle which will enable you to execute SQL queries directly by calling getDBHandle() method on connected POT instance.
As you probably noticed the only one file which you include is OTS.php. But you have to keep all POT files in one directory. If you wan't to have main file somewhere in your autoloaded directories and keep your directories tree clean from all additional POT files, you can use setPOTPath() method:
So to put that all together, in order to start working with POT you have to:
When you will use POT also for working with non-database resources then you will also mostly have to load global instances for some of them.
| Prev | Up | Next |
| POT | POT | PHP 5.0 |