Download the PHP package indieteq/indieteq-php-my-sql-pdo-database-class without Composer

On this page you can find all versions of the php package indieteq/indieteq-php-my-sql-pdo-database-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 indieteq-php-my-sql-pdo-database-class

I am not maintaining this repository anymore and I would like to request you to find a better repo or make a fork of this repository!

PDO Database Class

A database class for PHP-MySQL which uses the PDO extension.

To use the class

1. Edit the database settings in the settings.ini.php

Note if PDO is loading slow change localhost to -> 127.0.0.1 !

2. Require the class in your project

3. Create the instance

4. Logs - Modify the read/write rights of the root folder

Everytime an exception is thrown by the database class a log file gets created or modified. These logs are stored in the logs directory. Which means the database class needs write access for the logs folder. If the files are on a webserver you'll have to modify the rights of the root folder otherwise you'll get a "Permission denied" error.

The log file is a simple plain text file with the current date('year-month-day') as filename.

Examples

Below some examples of the basic functions of the database class. I've included a SQL dump so you can easily test the database class functions.

The persons table

id firstname lastname sex age
1 John Doe M 19
2 Bob Black M 41
3 Zoe Chan F 20
4 Kona Khan M 14
5 Kader Khan M 56

Fetching everything from the table

Fetching with Bindings (ANTI-SQL-INJECTION):

Binding parameters is the best way to prevent SQL injection. The class prepares your SQL query and binds the parameters afterwards.

There are three different ways to bind parameters.

More about SQL injection prevention : http://indieteq.com/index/readmore/how-to-prevent-sql-injection-in-php

Fetching Row:

This method always returns only 1 row.

Result
id firstname lastname sex age
1 John Doe M 19

Fetching Single Value:

This method returns only one single value of a record.

Result
firstname
Zoe

Using the like keyword

Result
id firstname lastname sex age
4 Sekito Khan M 19

Fetching Column:

Result
firstname
John
Bob
Zoe
Kona
Kader

Delete / Update / Insert

When executing the delete, update, or insert statement by using the query method the affected rows will be returned.

Method parameters

Every method which executes a query has the optional parameter called bindings.

The row and the query method have a third optional parameter which is the fetch style. The default fetch style is PDO::FETCH_ASSOC which returns an associative array.

Here an example :

More info about the PDO fetchstyle : http://php.net/manual/en/pdostatement.fetch.php

EasyCRUD

The easyCRUD is a class which you can use to easily execute basic SQL operations like(insert, update, select, delete) on your database. It uses the database class I've created to execute the SQL queries.

Actually it's just a little ORM class.

How to use easyCRUD

1. First, create a new class. Then require the easyCRUD class.

2. Extend your class to the base class Crud and add the following fields to the class.

Example class :

EasyCRUD in action.

Creating a new person

Deleting a person

Saving person's data

Finding a person

Getting all the persons

Copyright and license

Code released under Beerware


All versions of indieteq-php-my-sql-pdo-database-class with dependencies

PHP Build Version
Package Version
Requires php Version >=5.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 indieteq/indieteq-php-my-sql-pdo-database-class contains the following files

Loading the files please wait ....