Download the PHP package tatarko/dibi-active-record without Composer

On this page you can find all versions of the php package tatarko/dibi-active-record. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dibi-active-record

Dibi Active Record

Active Record built upon dibi Database Abstraction Library.

Latest Stable Version Code Climate

Requirements

DibiActiveRecord requires to run correctly:

Instalation

Composer

Simply add a dependency on tatarko/dibi-active-record to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a dependency on Dibi Active Record:

Getting started

To use dibi active record you simply define model's class that extends common parent class ActiveRecord from this repository.

Definying model's class

Basic manipulation with model

After we have successfully defined our first model, we can work with it in common way used in active record/orm patterns.

Different table/primary key names

By default, name of the active record's table equals to class name without namespace prefix and primary key name equals to id. In case that you want to change it, you can override tableName() and primaryKeyName() methods:

Usefull methods

Searching for rows

More searching criteria

Following methods can be called more multiple times - their effect is combined:

Following methods creates specified case of condtions. Argument $onHaving decides whether condition will be added to the WHERE statement (on false value) or to the HAVING statement (on true value). Argument $operator represents operator to be used before current condition (if it is not the first), AND by default. All the methods can be called multiple times with their effect to be combined.

Filters

Filters for Dibi Active Record is something like dynamic setter/getter for model's attribute. It can be defined by overriding filters() method.

Filters can used when getting model's attributes as object properties. If attributes are accessed as array elements then value is returned in its raw format.

List of pre-defined filters

Custom filters

New filter can be created by implementing Tatarko\DibiActiveRecord\FilterInterface interface and defiying it filters() method.

Validators

For validating model's attributes before inserting/updating to the database it is possible to set of validation rules to be performing before each saving operation. It can be achieved by overriding validators() method.

List of pre-defined validators

Validation in action

Validation is automatically triggered on model saving. In case that model is not valid, saving process is stopped. Validation can be skipped by filling $validate argument - $model->save(false)

Custom validators

New validator can be created by creating new class that extends Tatarko\DibiActiveRecord\ValidatorAbstract.

Relations

In case that multiple tables are connected using foreign keys, thier records records can be mapped in Dibi Active Record as properties. Relations can be defined in relations() method.

After definying relations we can use them as model's properties.

Events

In every model you can override following methods that will be triggered on specific occasions. In case of before... events, the process itself can be stopped if event method returns false.

ActiveFinder

Class ActiveFinder (which is ancestor for ActiveRecord) is used for working with DB views. It shares common logic with ActiveRecord except of saving/deleting rows, validating and events.


All versions of dibi-active-record with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
dibi/dibi Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tatarko/dibi-active-record contains the following files

Loading the files please wait ....