Download the PHP package p810/mysql-helper without Composer

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

mysql-helper

A fluent query builder and lightweight data mapper for MySQL

Installation

This package is available through Packagist.

Getting started

Using the query builder

Connect to MySQL with a new instance of p810\MySQL\Connection:

Note: For more connection options, see the documentation.

Then use the builder factory methods to fluently build your SQL queries with a p810\MySQL\Builder\BuilderInterface object:

The available factory methods are select(), insert(), update(), delete(), and replace(). To run a query and get its PDOStatement object (rather than process the results), you can run p810\MySQL\Connection::query():

query() also supports binding input for prepared statements. Just pass an array after the query.

Entities and data mappers

You can make models of your domain logic by implementing p810\MySQL\Mapper\EntityInterface. These models can be mapped to MySQL via implementations of p810\MySQL\Mapper\MapperInterface. Most mappers should extend p810\MySQL\Mapper\DefaultMapper, as it handles most operations out of the box:

:bulb: Note: The $key property is optional, but setting it allows you to use live entities, which are explained below. These entities have first class support for Active Record style methods, e.g. Row::save().

When running a query via a mapper, you have the option to manipulate the p810\MySQL\Query that it generates by passing a callback to the method call:

:bulb: Note: It's recommended that you specify your query's constraints in methods belonging to your mapper. Be careful not to run a CRUD method via the mapper without manipulating the query unless you have an absolute use case, otherwise you will end up with potentially large result sets or dangerous side effects. For example, DefaultMapper::delete() without any customization will delete every row in the table represented by your mapper.

If you want to run a generic query against the p810\MySQL\Connection, you can pass it through MapperInterface::query() which has the same signature as Connection::raw().

Live entities

For users who are more accustomed to Active Record inspired models, your mapper may extend p810\MySQL\Mapper\RowMapper which provides all the functionality of p810\MySQL\Mapper\DefaultMapper, but returns instances of p810\MySQL\Mapper\Row which wrap your entity and mapper for a less verbose experience:

For more information on what's possible with the query builder and data mapper, check out the documentation.

Development

Unit testing

A file named .db.env is loaded when PHPUnit is run, to get database connection options. An example of this file's contents can be found in .db.env.example. To change the location of this file, modify the environment variable in phpunit.xml. To point the migration script to an alternate file you can pass the -f or --file flag with the relative path to your file.

Code quality

License

This package is released under the MIT License.


All versions of mysql-helper with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
ext-pdo Version *
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 p810/mysql-helper contains the following files

Loading the files please wait ....