Download the PHP package primal/record without Composer

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

Primal Record

Created and Copyright 2013 by Jarvis Badgley, chiper at chipersoft dot com.

Primal Record is an Active Record ORM library for manipulating individual tables rows as arrays, designed to be extremely lightweight and extensible for maximum flexibility. It is recommended that Primal Record be used in a Data Mapper capacity, but can be used as a direct data model if so desired.

Primal is a collection of independent micro-libraries for simplifying common PHP tasks.

PLEASE NOTE THAT RECORD 2.0 IS IN ALPHA STATUS AND IS SUBJECT TO IMPLEMENTATION CHANGES

Usage

Primal Record is an abstract class and must be extended to function. For rapid development, the only implementation requirement is the definition of a table name. Primal Record will automatically request the table schema from your database, caching the structure for later usage.

Lets say you have the following table to interact with:

First create your record implementation for that table.

Once this implementation is created, you are ready to interface with table rows.

For the following examples, it is assumed that the following code has already executed:

Getting & Setting Row Data

Primal Record extends the built in PHP ArrayObject class. All row data is accessed on the object as if the Record object were an array:

Record also implements the __get and __set methods to allow for getting and setting the contents as properties on the object.

This is not a recommended method, however, as it removes the separation of implementation data (member properties) and external data (database rows).

Saving Rows

The save() function will perform a smart save of the row contents. If the primary keys match an existing row in the database, save will perform an update. If they do not match, or the auto-incrementing primary key was left undefined, save will perform an insert and update the record object with the new auto-incremented column value.

If it is known that the record does or does not exist, you can also call the insert() and update() functions explicitly. Calling insert(true) will perform a row replacement (REPLACE vs INSERT). A further shortcut is provided for saving as an entirely new row; calling save(true) will remove the auto-incrementing primary key and trigger an insert of a brand new row.

Saving Partial Row Contents

Only the values that have been defined on the Record object will be included in the INSERT and UPDATE calls.

Calling save or update will update the database with all the values defined within the Record. If you only wish to update a single then you may use the set() function.

The second argument on set() may be omitted to trigger an updating using whatever value is defined in the record (or NULL if nothing is defined).

Loading Rows

The load() function supports three methods of interaction:

  1. Single primary key loading: $row->load($value);
  2. Single non-primary key loading: $row->load($value, 'column_name');
  3. Multi-key loading: $row->load(array('column_1'=>'foo', 'column_2'=>8));

In all three cases, load() will return a boolean condition indicating if a matching row was found. This result can also be retrieved from the public found property.

For convenience, the load arguments can be passed directly on the class constructor:

Pre-caching Table Structure

If your table schema has been locked down and will not be changing, performance can be gained by pre-creating the schema structure array in your class definition.

This structure can be made by hand, but is much easier to obtain by code using the var_export function in conjunction with ->buildTableSchema():


All versions of record with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.7
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 primal/record contains the following files

Loading the files please wait ....