Download the PHP package gorgo/golibdatabase without Composer
On this page you can find all versions of the php package gorgo/golibdatabase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gorgo/golibdatabase
More information about gorgo/golibdatabase
Files in gorgo/golibdatabase
Package golibdatabase
Short Description Database layer
License MIT
Homepage https://github.com/swaros/golib-database
Informations about the package golibdatabase
golib-database
golib database layer
install
composer composer require gorgo/golibdatabase
basic usage
connect to a mysql Database
Connection Manager
is written for cases you can not be sure the connection is already existing (for example by replacing a singelton db implementation)
Table Example
Explain by example.
Table Structure and Content.
step 1: Build a Propertie Class that reflects the structure of the database.
this class have to extend from golib\Types\PropsFactory
Like so:
Step 2: Define the Table Class that points to the table, and setup the Propertie Class and the Tablename.
That is all what is needed to setup the basic Model for a Table. to read from this this table you make a new instance of these class and fetch the Data by using a existing Database Connection.
Now we have a Modell of the Database Table as an PHP-Object this will read the full content of the Table and assign it to row-objects.
WhereSet
But mostly you don't need the whole Content. in MySQL you handle this by adding
a where
statement to filter the result.
The same can be done by using a WhereSet
.
so change the code in the example
now we will got the matching values only.
Limit
The Limit
class is usefull to Limit the Amount of entries like the regular
Limit from MySQL. A instance of Limit have to be the second Parameter.
this object have just to Properties. start
defines the offset and count
the
count of entries.