Download the PHP package granadaorm/granada without Composer

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

Granada

Latest Stable Version Total Downloads Build Status

Granada is a easy to use Active Record implementation, and ORM based on Idiorm/Paris.

A quick view

You can read the Paris Docs on paris.readthedocs.org but be sure to read the additions below.

Install

Using composer:

Configure it:

As always, you can check it in detail on Paris documentation

Additions

Eager loading

You can use the "with" method to add relationships eager loading to the query.

will use 3 querys to fetch the users and the relationships:

It is possible to get the relationships results for each result, this way

Lazy loading

Triying to access to a not fetched relationship will call and return it

Notice that if there is no result for avatar on the above example it will throw a Notice: Trying to get property of non-object... Note: Maybe worth the effort to create a NULL object for this use case and others.

Lazy finds

find_many_lazy() is find_many() for big tables. Use it when the result is too big to hold in memory, for example a report over many thousands of rows. The loop looks the same, but your script holds one model at a time:

The order and the array keys are the same as find_many() gives you.

The chunk size

The method loads the rows in chunks. The first argument is the chunk size. The default is 1000:

A smaller chunk uses less memory and runs more queries. A bigger chunk does the opposite. The results you get are identical.

Eager loading

with() works as usual. The relationship query runs once per chunk, not once per model:

Loop only once

The method returns a generator. A generator cannot restart. To loop again, call find_many_lazy() again. Each call runs the queries again, so the data may have changed.

Queries the method refuses

The method throws an exception when the query has one of these:

If you turned on return_result_sets, it does not apply here: the method always returns a generator.

For small results, keep using find_many().

Eager loading with query control

Use with_{relation}() to eager-load a relationship and optionally configure the query via a callback:

Mix with the existing with() method:

Nested eager loading via with_* inside the callback:

Auto-included columns. You don't need to specify the columns the ORM uses for matching. They are added automatically:

Relationship type Column auto-added
belongs_to The related model's primary key
has_one, has_many The foreign key on the related table

If you already include these columns in your select(), they won't be added twice.

Column names. Use comma-separated strings for multiple columns: select('id, name'). Do not use select('id', 'name') - the second argument is an alias.

has_many_through. Qualify column names with the table because the query involves a join:

Chained relationships with arguments for eager loading

It is possible to chain relationships and add arguments to the relationships calls

Custom query actions

We use a query class to build filters for a query. To add custom filters to a Query model, create a Query<ModelName> class that extends \Granada\Query.

and call it through q():

Multiple additions names for Granada

Overload SET

Mass assignment

create() and set() write every key they are given. There is no fillable or guarded list to declare: Granada does not know what is safe to write, and the model does not filter for you.

If the array comes from a request, keep only the fields the request was meant to set before it reaches the model:

Unknown keys are not dropped. They are stored like any other field, and the save fails with a database error if the column does not exist. Filtering request data is the caller's job, because the caller is the one who knows the fields the form offered.

Overload GET and MISSING property

Of course, you still can define functions with the property name if you want to overload it completely.

Define resultSet (collection type) class on Model

Now is possible to define the resultSet class returned for a model instances result. (if return_result_sets config variable is set to true) Notice that the resultSet class defined must extends Granada\ResultSet and must be loaded

ResultSets are defined by the model in the result, as you can see above. On eager load, the results are consistent. For example, if we have a Content model, with $resultSetClass = 'TreeResultSet' and a has_many relationship defined as media:

will return a TreeResultSet with instances of Content each with a property $media containing Granada\ResultSet (the default resultSet if none if defined on the Model)

Basic Documentation comes from Paris

Paris

Feature complete

Paris is now considered to be feature complete as of version 1.4.0. Whilst it will continue to be maintained with bug fixes there will be no further new features added.

A lightweight Active Record implementation for PHP5.

Built on top of Idiorm.

Tested on PHP 5.2.0+ - may work on earlier versions with PDO and the correct database drivers.

Released under a BSD license.

Features

History

Granada was originally developed by Erik Wiesenthal, up to version 1.5. Further development started by Josh Marshall to release version 2.0


All versions of granada with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 granadaorm/granada contains the following files

Loading the files please wait ...