Download the PHP package cakephp/database without Composer

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

Total Downloads

A flexible and lightweight Database Library for PHP

This library abstracts and provides help with most aspects of dealing with relational databases such as keeping connections to the server, building queries, preventing SQL injections, inspecting and altering schemas, and with debugging and profiling queries sent to the database.

It adopts the API from the native PDO extension in PHP for familiarity, but solves many of the inconsistencies PDO has, while also providing several features that extend PDO's capabilities.

A distinguishing factor of this library when compared to similar database connection packages, is that it takes the concept of "data types" to its core. It lets you work with complex PHP objects or structures that can be passed as query conditions or to be inserted in the database.

The typing system will intelligently convert the PHP structures when passing them to the database, and convert them back when retrieving.

Connecting to the database

This library is able to work with the following databases:

The first thing you need to do when using this library is create a connection object. Before performing any operations with the connection, you need to specify a driver to use:

Drivers are classes responsible for actually executing the commands to the database and correctly building the SQL according to the database specific dialect. Drivers can also be specified by passing a class name. In that case, include all the connection details directly in the options array:

Connection options

This is a list of possible options that can be passed when creating a connection:

Using connections

After creating a connection, you can immediately interact with the database. You can choose either to use the shorthand methods execute(), insert(), update(), delete() or use the newQuery() for using a query builder.

The easiest way of executing queries is by using the execute() method, it will return a Cake\Database\StatementInterface that you can use to get the data back:

Binding values to parametrized arguments is also possible with the execute function:

The third parameter is the types the passed values should be converted to when passed to the database. If no types are passed, all arguments will be interpreted as a string.

Alternatively you can construct a statement manually and then fetch rows from it:

The default types that are understood by this library and can be passed to the bind() function or to execute() are:

More types can be added dynamically in a bit.

Statements can be reused by binding new values to the parameters in the query:

Updating Rows

Updating can be done using the update() function in the connection object. In the following example we will update the title of the article with id = 1:

The concept of data types is central to this library, so you can use the last parameter of the function to specify what types should be used:

The example above will execute the following SQL:

More on creating complex where conditions or more complex update queries later.

Deleting Rows

Similarly, the delete() method is used to delete rows from the database:

Will generate the following SQL

Inserting Rows

Rows can be inserted using the insert() method:

More complex updates, deletes and insert queries can be generated using the Query class.

Query Builder

One of the goals of this library is to allow the generation of both simple and complex queries with ease. The query builder can be accessed by getting a new instance of a query:

Selecting Fields

Adding fields to the SELECT clause:

Where Conditions

Generating conditions:

As you can see you can use any operator by placing it with a space after the field name. Adding multiple conditions is easy as well:

It is possible to generate OR conditions as well

For even more complex conditions you can use closures and expression objects:

Which results in:

Combining expressions is also possible:

That generates:

When using the expression objects you can use the following methods to create conditions:

Aggregates and SQL Functions

A number of commonly used functions can be created with the func() method:

When providing arguments for SQL functions, there are two kinds of parameters you can use, literal arguments and bound parameters. Literal parameters allow you to reference columns or other SQL literals. Bound parameters can be used to safely add user data to SQL functions. For example:

The above generates:

Other SQL Clauses

Read of all other SQL clauses that the builder is capable of generating in the official API docs

Getting Results out of a Query

Once you’ve made your query, you’ll want to retrieve rows from it. There are a few ways of doing this:

Official API

You can read the official official API docs to learn more of what this library has to offer.


All versions of database with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
cakephp/core Version ^5.0
cakephp/chronos Version ^3.0.2
cakephp/datasource Version ^5.0
psr/log Version ^3.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 cakephp/database contains the following files

Loading the files please wait ....