Download the PHP package jameslevi/hadron without Composer
On this page you can find all versions of the php package jameslevi/hadron. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jameslevi/hadron
More information about jameslevi/hadron
Files in jameslevi/hadron
Package hadron
Short Description Is a simple PHP library for MySQL using PDO.
License MIT
Informations about the package hadron
Hadron
Is a simple PHP library for MySQL using PDO.
Installation
-
You can install via composer.
-
Paste the following code above your project if not using any PHP framework.
- Import hadron into your project.
The Basics
This is a basic example on how to implement hadron in your project.
Connecting with your MySQL database
-
Create a new hadron instance.
-
You can also use this magic method.
-
Set your MySQL credentials.
-
You can also set your server name.
-
You can set your MySQL port number if not using 3306.
-
Set the default charset from utf8mb4 to your choice.
-
The connection will only be established after calling the connect method.
-
You can determine if connection was established using isConnected method.
- Always close each connection after use.
Getting data from the database
-
Use get method when your query expects result from the database.
-
You can count the number of rows returned.
-
You can check if the query returns nothing.
-
You can get the first and the last row of the result.
-
You can also get row by index number.
-
If query returns only a single row, you can directly get each column.
-
And if query returns a multiple row, you can access each column like object properties.
-
You can return the result as an array.
- You can also return the result as json.
Executing Queries
-
You can use exec method to execute queries expecting no results such as UPDATE, INSERT and DELETE.
-
You can determine if query is a success.
- You can also know how many rows your query has affected.
Placeholder
Instead of concatenating string to build your SQL query, you can use placeholder to inject values into your SQL query.
You can also directly pass your placeholder in the query method.
Contribution
For issues, concerns and suggestions, you can email James Crisostomo via [email protected].
License
This package is an open-sourced software licensed under MIT License.