Download the PHP package peacq/picorm without Composer

On this page you can find all versions of the php package peacq/picorm. 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 picorm

a lightweight PHP ORM.

PicORM will help you to map your MySQL database rows into PHP object and create relations between them.
PicORM is an Active Record pattern implementation easy to install and use.

Build Status Latest Stable Version Total Downloads

Some stuff you need to know

Install

From composer

Install composer in your www folder with curl -sS https://getcomposer.org/installer | php

Create a composer.json file with

Install PicORM with php composer.phar install

From source
Clone https://github.com/iNem0o/PicORM repository and include PicORM autoload with

Load and configure PicORM
Before using PicORM you have to configure it. datasource is the only required parameter and have to be a PDO instance

Model

Implements a Model
First you have to create a table, which your model will be mapped to

Next create a class which extends \PicORM\Model You have to implements some static parameters to describe your MySQL table schema, if you forgot one of them, a \PicORM\Exception will remind you

Required
protected static $_tableName MySQL table name
protected static $_primaryKey table primary key field name
protected static $_tableFields array with all mysql table fields name without primary key

Optional
protected static $_databaseName name of the database if different from datasource main DB

and then, add one public property by table field with public $fieldName

Brand model declaration

Create and save

Update and delete

find() and findOne()

Every subclass of Model inherit of static methods find() and findOne().
Theses methods are used to hydrate models from database rows.

How to use $where parameter
this parameter is data for building a WHERE mysql clause

How to use $order parameter
This parameter is data for building an ORDER mysql clause

Collections

Collections in PicORM are created by ::find() method, accessible statically on each \PicORM\Model subclass.
Once you have a fresh \PicORM\Collection instance, data is not fetched yet. Fetching is done only when you try to access data using one of these ways

Collections usage

An \PicORM\Collection instance can execute UPDATE and DELETE queries on the collection members before fetching data, this way using update() or delete() method produce only one MySQL query based on find() restriction parameters.

Collections pagination

Pagination in collection is based on MySQL FOUND_ROWS(). Remembering that collection is not fetched until you use it, when you have a Collection instance, its easy to activate pagination with

You have now access to 2 more methods.

Collection advanced query

You are able to alter the fetch query before it execution using the method on the collection. You will get an instance of which you can manipulate. Once you are done, just set the collection query helper with

That way you can load custom data inside a model instance.

Relations between models

Using relations will need you to add a property and a method to your model subclass.
protected static $_relations = array(); needed to be implemented to store model relations protected static function defineRelations() { } method to declare your relation

overriding defineRelations() in your subclass allow you to declare your model specific relations using one of the 3 next methods.

Using relation

This example will use the following MySQL schema

First you have to declare your 3 models and their relations

Now you can start to create and manipulates related models

As you declare a one to many relation from Brand to Car you can also using setter and getter on the other side

Many to many relations are easy to use too

Changelog

UNSTABLE 0.0.1

UNSTABLE 0.0.2

BETA 0.0.3

BETA 0.0.4

BETA 0.0.5

BETA 0.0.6


All versions of picorm with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.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 peacq/picorm contains the following files

Loading the files please wait ....