Download the PHP package jr-cologne/db-class without Composer

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

db-class

Build Status

This project is a simple database class with PHP, PDO and a query builder.

The class extends PDO for more control and in order to keep all features of PDO.

Requirements

Installation

If you want to use the database class for your own project, you have two options to install it:

Using Composer (recommended)

Once you have installed Composer, execute this command:

Then you just have to include the autoloader:

Manual Installation

  1. Download the ZIP file of this project
  2. Unzip it and move everything to your own project directory.
  3. Include all files of the database class into your project like that:

Now you should be ready to start!

Basic Usage

Namespace

Before instantiating the class, always make sure to use the right namespaces:

Instantiating Class

To be able to use the class, you have to instantiate it.

Just do this:

Connecting to Database

You can connect to a database with the help of the method DB::connect().

An simple example:

Checking Connection to Database

You can also check the connection to the database by the method DB::connected() after connecting.

Example:

Retrieving Data from Database

In order to retrieve data from a database, you need to walk through the following three steps:

  1. Choose a table with the method DB::table().
  2. Select the data you want to retrieve.
  3. Retrieve the selected data.

Fortunately, this is super simple with the database class:

It will basically retrieve all records from the selected table.

Inserting Data into Database

If you want to insert data into a database, you have two methods which you can use:

In this case, we are just going to insert one row.

The procedure is as follows:

  1. Choose a table with the method DB::table().
  2. Insert the data with the method DB::insert().

Example:

Updating Data from Database

In case you want to update data from a database, you can use the method DB::update().

The following steps are required:

  1. Choose a table with the method DB::table().
  2. Update the data with the method DB::update().

Example:

This will update the record(s) where the username is equal to test and the password is equal to password to test123 for the username and password123 for the password.

Deleting Data from Database

In order to delete data from a database, follow these steps:

  1. Choose a table with the method DB::table().
  2. Delete the data with the method DB::delete().

Here's an simple example which deletes the record(s) where the username is equal to test:

Custom Where Clauses

Custom Logical Operators in Where Clause

Since the release of version 2.3, a where clause can also have custom logical operators.

This is how a where clause with custom logical operators could look like when retrieving data from a database:

Custom Comparison Operators in Where Clause

Since the release of version 2.4, a where clause can also have custom comparison operators.

This is how a where clause with custom comparison operators could look like when retrieving data from a database:

Using PDO's functionality

Since the database class is extending PDO, you can use the whole functionality of PDO with this class as well.

Just connect to the database using the method DB::connect() and after that simply use everything as normal.

An quick example:

API

Looking for a complete overview of each class, property and method of this database class?

Just head over to the API.md file where you can find everything you need.

It is located in the source (src) folder.

Further Examples / Stuff for Testing

You want to see further examples of using the database class or you just want to play around with it a little bit?

Contributing

Feel free to contribute to this project! Any kind of contribution is highly appreciated.

In case you have any questions regarding your contribution, do not hesitate to open an Issue.

Versioning

This project is using the rules of semantic versioning (since version 2). For more information, visit semver.org.

License

This project is licensed under the MIT License.


All versions of db-class with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 jr-cologne/db-class contains the following files

Loading the files please wait ....