Principe Orazio - 2012-08-06

A little explanation about DBPersister package

= Introduction =

About

DBPersister started in 2011 with few lines of code to enhance the way to develop crud applications by php users.

DBPersister is an Open Source project with LGPL licence , which means that is possible to reach hundreds of people all over the world working on it with the possibility to edit the code depending own needs.
About DBPersister

On this site you can download and use a list of libraries in all your php projects that use mysql as database. To do use this libraries you need mysqli extension installed on your web host without any other components.
What You Can Use DBPersister For

You can use DBPersister to manage data from your database to your application. You can do all boring operations like :

load single record
save single record (insert, update, replace)
delete single record
and many others operations

without writing SQL code by yourself.
Connect with the Community

In addition to online resources like the forum and our facebook page is a great way to get involved with DBPersister.
About us
The project was created by Orazio Principe and supported by Fabio Greco.

= Details =

GETTING STARTED

Use the library DBPersister is really simple, here what you need:
1 – Download the installation file dbpersister_setup.zip , unzip it, and save the file dbpersister_setup.php to any directory within your web server can access. For example, if you are working locally, and the site you are developing can be reached at the address “localhost”, you may save the setup file in the root directory of your local server and then type in any web browser the following address: “http://localhost/dbpersister_setup.php”.
2 – In this step you will find a form that asks some credentials. Enter the host address that runs your mysql server, type the username and password used to access your database and the name of database to use.
(Note: this username need all privileges to read the mysql own database if you choose to build from scratch all classes)
3 – Choose the directory for your project, the default is set to the directory where you saved the setup file.

Now you can click the red button that says “Setup DBPersister library” as the image below:

Screenshot for DBPersister installer

the automatic procedure will create/update inside your project everything you need to start being productive. The program will create the following files:

Castable.php

DbMySql_initializer.php

DbMySql_Persister.php

DbMySqli_Settings.php

which are the library files. Also will create, always in the same directory, all classes mapping all the tables in your database: these are the files that you really need to start working by.
Alternatively you can make sure that the procedure creates only the library files, leaving you the task of creating by hand classes that map your tables. In that case just put the check mark on “I do not want to automatically map my tables, only install the library”.
On the homepage you can see an example of how to map a table creating a mapping file.

In fact, with the automatic installation, you don’t need to create classes that map to your tables, and neither the class for settings up database parameters , which is automatically created

Let’s take this simple example. I am a daredevil and I followed the installation procedure. And now what else have i to do?
Well, imagine that the test database contains a single table, the table “users”. The table “users” has an “id” field (primary key, auto_increment), a field “username” and “password” field.
The DBPersister installation procedure has created four php files mentioned above inside the directory “my_test_directory” and users.php file in the same directory.
What we simply do in our program is to include the php files users.php in the standard way, and use the class users in the standard mode in which you use objects in php language.

 

Last edit: Principe Orazio 2012-08-06