Download the PHP package josantonius/database without Composer

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

PHP Database library

Latest Stable Version

Versión en español

SQL database management to be used by several providers at the same time.



Requirements

This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.

Installation

The preferred way to install this extension is through Composer.

To install PHP Database library, simply:

composer require Josantonius/Database

The previous command will only install the necessary files, if you prefer to download the entire source code you can use:

composer require Josantonius/Database --prefer-source

You can also clone the complete repository with Git:

git clone https://github.com/Josantonius/PHP-Database.git

Or install it manually:

Download Database.php, Provider.php, PDOprovider.php, MSSQLprovider.php and DBException.php:

wget https://raw.githubusercontent.com/Josantonius/PHP-Database/master/src/Database.php
wget https://raw.githubusercontent.com/Josantonius/PHP-Database/master/src/Provider/Provider.php
wget https://raw.githubusercontent.com/Josantonius/PHP-Database/master/src/Provider/PDOprovider.php
wget https://raw.githubusercontent.com/Josantonius/PHP-Database/master/src/Provider/MSSQLprovider.php
wget https://raw.githubusercontent.com/Josantonius/PHP-Database/master/src/Exception/DBException.php

Get connection

- Get connection

Attribute Description Type Required Default
$id Database unique ID. string Yes
$provider Name of provider class. string No null
$host Database host. string No null
$user Database user. string No null
$name Database name. string No null
$password Database password . string No null
Attribute Key Description Type Required Default
$settings Database options. Once the connection is made, this configuration will be available in the database connection object: $db->settings. array No null
$settings 'port' Database port. string No
$settings 'charset' Database charset. string No

# Return (object) → object with the connection

Query

- Process query and prepare it for the provider

Attribute Description Type Required Default
$query Query. string Yes
$statements Statements. array No null
$result Query result; 'obj', 'array_num', 'array_assoc', 'rows', 'id'. string No 'obj'

# Return (mixed) → result as object, array, int...

# throws [DBException] → invalid query type

CREATE TABLE

- CREATE TABLE statement

Method Attribute Description Type Required Default
$data Column name and configuration for data types. array Yes
table() Set database table name. method Yes
$table Table name. string Yes
foreing() Set foreing key. method No
$id Column id. string Yes
reference() Set reference for foreing keys. method No
$table Table name. array Yes
on() Set database table name. method No
$table Table name. array Yes
actions() Set actions when delete or update for foreing key. method No
$action Action when delete or update. array Yes
engine() Set table engine. method No
$type Engine type. string Yes
charset() Set table charset. method No
$type Charset type. string Yes
execute() Execute query. method Yes

# Return (boolean)

SELECT

- SELECT statement

Method Attribute Description Type Required Default
$columns Column/s name. mixed No '*'
from() Set database table name. method Yes
$table Table name. string Yes
where() Where clauses. method No
$clauses Column name and value. mixed Yes
$statements Statements. array No null
order() Order. method No
$type Query sort parameters. string Yes
limit() Limit. method No
$number Number. int Yes
execute() Execute query. method Yes
$result Query result; 'obj', 'array_num', 'array_assoc', 'rows'. string No 'obj'

# Return (mixed) → query result (object, array, int...) or rows affected

INSERT INTO

- INSERT INTO statement

Method Attribute Description Type Required Default
$data Column name and value. array Yes
$statements Statements. array No null
in() Set database table name. method Yes
$table Table name. string Yes
execute() Execute query. method Yes
$result Query result; 'rows', 'id'. string No 'rows'

# Return (int) → rows affected or last row affected ID

UPDATE

- UPDATE statement

Method Attribute Description Type Required Default
$data Column name and value. array Yes
$statements Statements. array No null
in() Set database table name. method Yes
$table Table name. string Yes
where() Where clauses. method No
$clauses Column name and value. mixed Yes
$statements Statements. array No null
execute() Execute query. method Yes

# Return (int) → rows affected

REPLACE

- Replace a row in a table if it exists or insert a new row if not exist

Method Attribute Description Type Required Default
$data Column name and value. array Yes
$statements Statements. array No null
from() Set database table name. method Yes
$table Table name. string Yes
execute() Execute query. method Yes
$result Query result; 'rows', 'id'. string No 'rows'

# Return (int) → rows affected or last row affected ID

DELETE

- DELETE statement

Method Attribute Description Type Required Default
$data Column name and value. array Yes
$statements Statements. array No null
from() Set database table name. method Yes
$table Table name. string Yes
where() Where clauses. method No
$clauses Column name and value. mixed Yes
$statements Statements. array No null
execute() Execute query. method Yes

# Return (int) → rows affected

TRUNCATE TABLE

- TRUNCATE TABLE statement

Method Attribute Description Type Required Default
table() Set database table name. method Yes
$table Table name. string Yes
execute() Execute query. method Yes

# Return (boolean)

DROP TABLE

- DROP TABLE statement

Method Attribute Description Type Required Default
table() Set database table name. method Yes
$table Table name. string Yes
execute() Execute query. method Yes

# Return (boolean)

Quick Start

To use this class with Composer:

Or If you installed it manually, use it:

Supported datatypes for prepared statements

Boolean

Null

Integer numbers

Text strings

If any type of data that does not match the aboves, it will be validated as a string.

If no data type is specified, the data type will not be validated in the prepared query.

Tests

To run composer and to execute the following:

git clone https://github.com/Josantonius/PHP-Database.git

cd PHP-Database

composer install

Run unit tests with PHPUnit:

composer phpunit

Run PSR2 code standard tests with PHPCS:

composer phpcs

Run PHP Mess Detector tests to detect inconsistencies in code style:

composer phpmd

Run all previous tests:

composer tests

Sponsor

If this project helps you to reduce your development time, you can sponsor me to support my open source work :blush:

License

This repository is licensed under the MIT License.

Copyright © 2017-2022, Josantonius


All versions of database with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0
eliasis-framework/eliasis Version ^1.1.3
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 josantonius/database contains the following files

Loading the files please wait ....