Download the PHP package dealnews/db without Composer

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

DealNews Datbase Library

Factory

The factory creates PDO objects using DealNews\GetConfig to read database settings (from [app home]/etc/config.ini) and create a PDO database connection.

Supported Settings

Setting Description
type This may be one of pdo, mysql, or pgsql. All types return PDO connections.
dsn A valid PDO DSN. See each driver for specifics
db The name of the database. For PDO, this is usually in the DSN.
server One of more comma separated servers names. Not used by the pdo type.
port Server port. Not used by the pdo type.
user Database user name. Not all PDO drivers require one.
pass Database password. Not all PDO drivers require one.
charset Character set to use for mysql connections. The default is utf8mb4.
options A JSON encoded array of options to pass to the PDO constructor. These vary by driver.

Example config.ini file

This file should be stored in a directory named etc in the application's home directory.

Usage

Example:

CRUD

The CRUD class is a helper that wraps up common PDO logic for CRUD operations.

Basic Usage

Advanced Usage

The class also exposes a run method which is used internally by the other methods. Complex queries can be run using this method by providing an SQL query and a parameter array which will be mapped to the prepared query. It returns a PDOStatement object.

Data Mapper Pattern

This library includes an abstract mapper class for creating data mapper classes. The data mapper pattern separates the object from how it is stored. A value object is created and a data mapper that is responsible for CRUD operations to and from a datastore.

To load, save, delete, etc. the mapper is used like so.

Generating Value Objects and Mappers

This library includes a script for generating value objects and mappers. It has been tested and works with MySQL and PostgreSQL. Once installed in your project, the script can be run from the vendor/bin directory.

Base Class for Value Objects

This library will work with plan PHP classes that do not extend any other class. However, using a base class such as Moonspot\ValueObjects can make working with the value objects easier.

Nested Mappers, Relational Data, and More

Documentation coming

Query Builder

The Query class provides a fluent interface for building complex SELECT queries with JOINs, subqueries, GROUP BY, HAVING, and more. It complements CRUD for queries that go beyond simple single-table operations.

Basic Usage

Complex Queries with JOINs

Nested WHERE Conditions

Available Methods

Method Description
select(array $columns) Set SELECT columns
from(string $table, ?string $alias) Set FROM table
join(), innerJoin(), leftJoin(), rightJoin() Add JOIN clauses
where(), orWhere() Add WHERE conditions
whereIn(), whereNotIn() Add IN conditions
whereNull(), whereNotNull() Add NULL checks
whereRaw(string $sql, array $params) Add raw WHERE SQL
groupBy(array $columns) Add GROUP BY
having(), orHaving() Add HAVING conditions
orderBy(string $column, string $direction) Add ORDER BY
limit(int $limit) Set LIMIT
offset(int $offset) Set OFFSET
getSql() Build and return the SQL string
getParams() Get the bound parameters
Query::raw(string $value, array $params) Create a raw SQL fragment

Testing

By default, only unit tests are run. To run the functional tests the host machine will need to be a docker host. Also, the pdo_pgsql, pdo_mysql, and pdo_sqlite extensions must be installed on the host machine. PHPUnit will start and stop docker containers to test the MySQL and Postgres connections. Use --group functional when running PHPUnit to run these tests.


All versions of db with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-pdo Version *
dealnews/console Version ^1.0.1
dealnews/data-mapper Version ^3.4
dealnews/get-config Version ^2.2
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 dealnews/db contains the following files

Loading the files please wait ...