Download the PHP package ceus-media/database without Composer

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

Database

Branch Release PHP version PHPStan level

PHP database access

Installation

Composer

Install this library using composer:

Within your code, load library:

Code Examples using PDO

Database Connection

Tables

Existing database tables can be declared as tables:

Table class

Table instance

Having this defined structure, you can use a table instance for reading from and writing into the database table. Hence that you need to create a database connection beforehand.

Reading an entry

Example for getting an entry by its primary key:

The result will be an object of table columns and their values, since the fetch mode is set to object-wise by table structure:

Not having the fetch mode set would result in an associated array, which is set as default fetch mode in underlaying table reader. To change the fetch see below.

Hint: There are more methods to retrive a single entry:

which allow to focus on foreign indices instead of the primary key.

Finding entries

A group of entries, filtered by a foreign key:

A group of entries, filtered by several foreign keys:

To get all entries, call:

which may be bad in scaling, so reduce the result set by defining limits and conditions:

Conditions can be indices or any other column.

Orders are pairs of columns and directions, like:

There are more parameters possible for each of this indexing methods, which allow:

Counting

To count entries by a foreign key:

To count entries, filtered by several foreign keys:

To get all entries, call:

which may be bad in scaling, so reduce the result set by defining conditions:

Hint: Counting having really large MySQL tables may be slow. There is a method to count in large tables in a faster way. You will find it.

Adding an entry

Attention: For security reasons, all HTML tags will be striped. Set second parameter to FALSE to avoid that, if needed. Make sure to strip HTML tags of none-HTML columns manually!

Updating an entry

where the result will be the number of changed entries.

Attention: For security reasons, all HTML tags will be striped. Set third parameter to FALSE to avoid that, if needed. Make sure to strip HTML tags of none-HTML columns manually!

Updating several entries

where the result will be the number of changed entries.

Attention: For security reasons, all HTML tags will be striped. Set third parameter to FALSE to avoid that, if needed. Make sure to strip HTML tags of none-HTML columns manually!

Removing an entry

where the result will be the number of removed entries.

Removing several entry

where the result will be the number of removed entries.

Change fetch mode

In your table structure class, set:

where YOUR_FETCH_MODE is one of these standard PDO fetch modes:

Code Examples using OSQL

Having a config file like this:

and assuming that you load things up like this:

you can connect to a database like this:

Now you can query the database like this:

The result will contain the requested rows (only one in this example):

will produce:


All versions of database with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-pdo Version *
ceus-media/common Version ^1.0 | 1.0.x-dev
ceus-media/cache Version ^0.5 | 0.5.x-dev
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 ceus-media/database contains the following files

Loading the files please wait ....