Download the PHP package cocur/nqm without Composer

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

cocur/nqm

Named Query Manager (NQM) helps you organise SQL queries in files.

Build Status Code Coverage

Features

Installation

You can install cocur/nqm using Composer:

Tip: Use a concrete version instead of @stable.

Usage

In order to use NQM you need to initialise the Cocur\NQM\NQM class with an instance of \PDO and a query loader. NQM comes with a FilesystemQueryLoader query loader.

After you have initialised the NQM object you can use it. Currently the class has three public methods to retrieve a query, prepare a statement or execute a statement.

The following command will return the SQL query stored in ./queries/find-all-users.sql.

NQM can also return a \PDOStatement object directly:

Or you can immediately execute the statement:

Query Cache

To speed up loading of queries you can use the Cocur\NQM\QueryLoader\CacheQueryLoader to cache queries. The cache class implements the same interface as the other query loaders and the constructor accepts an instance of QueryLoaderInterface. If a query does not exist in the cache, the cache uses this loader to load the query. For example,

APC Query Cache

The CacheQueryLoader query loader stores cached queries in an array and therefore only on a per-request basis. While this often suffices in CLI applications for web apps it would be better to cache queries over multiple requests.

Additionally if you have queries that you use more than once in a single request you can stack multiple query loaders. In the following example NQM will load queries from the array cache or if it's not cached it will look in the APC cache. As a last resort NQM loads the query from the filesystem.

Array Query Loader

Stores the queries in an array.

Query Collection

Sometimes you have multiple queries that are always executed together. For example, a DROP TABLE, CREATE TABLE sequence or if you have to create temporary tables for especially complex queries. Since PDO accepts only a single SQL statement per statement, you can use QueryCollection to execute multiple queries. Queries must be separated by #;, which must be placed on its own line.

The prepare() and execute() methods return both a Cocur\NQM\StatementCollection. This collection class implements \ArrayAccess and \Countable.

Doctrine Bridge

If you don't have a PDO object, but a Doctrine EntityManager object you can use the Doctrine bridge to create a new NQM object.

Change log

Version 0.4 (6 October 2015)

Version 0.3 (16 February 2015)

Version 0.2 (11 February 2015)

Version 0.1.2 (3 February 2015)

Version 0.1.1 (26 August 2014)

Version 0.1 (28 May 2014)

Author

Florian Eckerstorfer Support Florian

License

The MIT license applies to cocur/nqm. For the full copyright and license information, please view the LICENSE file distributed with this source code.


All versions of nqm with dependencies

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

Loading the files please wait ....