Download the PHP package nhrdev/nhr_db without Composer
On this page you can find all versions of the php package nhrdev/nhr_db. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nhrdev/nhr_db
More information about nhrdev/nhr_db
Files in nhrdev/nhr_db
Package nhr_db
Short Description This is a PDO based MySQL or MariaDB database helper library
License GPL-3.0-or-later
Informations about the package nhr_db
nhr_db
This PHP library will help you to create database connetion using PDO and creating tables,inserting,updating,fetching,deleting data from database without writing any SQL code.Just create an object of the "DB" class and then the power is yours! :)
How to install :
How to use :
- To connect
YOU MUST PASS AN ARRAY WITH THESE KEYS AND YOUR SPECIFIC VALUES TO CONNECT TO THE DATABASE.
driver host port and charset are optional.
driver is set to mysql and
host is set to localhost by default
-
To disconnect :
-
To connect if disconnected :
-
To check if connected or not :
- To create a new table :
To add columns after creating the table, after calling the create() method
-
To drop any table
- To drop all the columns or to drop the whole
TABLE_NAME
NOTE : col,add,drop,drop_all these methods will return the table object $table, so in this case so you can do method chaining like
-
To insert row into the table
-
To get the last inserted id This will return false if no insertion is made.
-
To update specific rows
-
To update all rows
-
To delete specific rows
-
To delete all rows
- To fetch rows
This function will return \NhrDev\NHR_DB\Src\Result object with some functions to access the fetched data.
Here DB::OBJ for object DB::ASSOC for associative array and DB::IND for indexed array
-
To get all the rows from the fetched data
-
To get the first row
-
To get the last row
- To loop through the rows
The second parameter is false by default. If you set this true then the loop will be in reverse order.
- To get a single row by INDEX
This will return false if you pass an index less than 0 or greater than the number of rows fetched