Download the PHP package mouf/database.querywriter without Composer

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

What is QueryWriter?

QueryWritter is a PHP library that parses SQL queries, transforms those into an object representation, stores them in a dependency injection container, and returns them as string. It is a Mouf plugin.

It is heavily based on mouf/magic-query. Actually, magic-query's code was extracted from query-writer.

Ok, but why would I use QueryWritter?

Because it is the most effecient way to deal with queries that can have a variable number of parameters! Think about a typical datagrid with a bunch of filter (for instance a list of products filtered by name, company, price, ...). If you have the very common idea to generate the SQL query using no PHP library, your code will look like this:

You should not do this!

Concatenating SQL queries is dangerous (especially if you forget to protect parameters). You can always use parameterized SQL queries, but you will still have to concatenate the filters.

To avoid concatenating strings, frameworks and libraries have used different strategies. Building a full ORM (like Doctrine or Propel) is a good idea, but it makes writing complex queries even more complex. Other frameworks like Zend are building queries using function calls. These are valid strategies, but you are no more typing SQL queries directly, and let's face it, it is always useful to use a query directly.

This is where QueryWritter becomes helpful.

How does it work?

// TODO: schema... or even better... video!

1- Write your query

You start by writing your query, in plain SQL. No ORM, no special query language (DQL or HQL anyone?), just plain and simple SQL. This is cool because everybody knows SQL. In your query, you put absolutely all the parameters you can imagine.

2- Store your query in Mouf

In Mouf UI, go to DB > SQL queries > Create SQL query. Here, you can copy and paste your query. Since this is Mouf, every query is an "instance", and you have to pick a name for your query.

Behind the scenes, QueryWritter will parse your query and make sure every piece of the query (each table, each column, each filter...) is transformed into an object. But you really don't have to care about that right now.

3- Test your query

Right from Mouf UI, you can test your query! And lo and behold! Because the query was parsed, QueryWritter will dynamically add parts of the query depending on the parameters you decide to use.

4- Use it in your code

If you are not a Mouf user (if you are using Drupal, Symfony, Zend Framework...), you can directly use the query by fetching the instance from Mouf and calling the toSql method, passing parameters in... parameter :)

If you are a Mouf user, you can even directly run the query using the QueryResult class that executes the query directly. Or even better, use the Evolugrid module, and display your query result in an HTML datagrid, directly!


All versions of database.querywriter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
mouf/database.doctrine-dbal-wrapper Version ~1.1
mouf/html.widgets.evolugrid Version ~4.0 | ~5.0 | ~6.0
mouf/magic-query Version ~1.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 mouf/database.querywriter contains the following files

Loading the files please wait ....