Free Functions To Connect To The Database ( Mysql ) For Php Programmers

Related tags

Miscellaneous DB-php
Overview

Update

🔥 The biggest update ever

DB-php

Free Functions To Connect To The Database ( Mysql ) For Php Programmers

This Version : 2.0

connect to database

connect(string $dbname,string $username_db,string $password_db,string $host = 'localhost');

This Function :

connect('dbName','myuser','passworduser');

Php :

        $Option = [
        PDO::ATTR_PERSISTENT => TRUE,
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::MYSQL_ATTR_INIT_COMMAND =>'SET NAMES utf8',
        PDO::ATTR_EMULATE_PREPARES => false
    ];
        $pdo = new PDO("mysql:host=localhost;dbname=dmn_nm;charset=utf8", "myAdmin" , 'abcdefgh1234' , $Option );

SQL Select Examples

select * from db where id = 10 limit 3

PHP :

$select = select('*','db',['id'=>10],'limit 3');

execute :

array (size=2)
  'count' => int 3
  'fetchAll' => 
    array (size=3)
      0 => 
        array (size=7)
          'id' => int 17
          'step' => string 'support' (length=7)
          'chat_id' => int 1212
          'Cash' => null
          'vip' => int 0
          'grade' => int 0
          'Download' => int 0
      1 => 
        array (size=7)
          'id' => int 18
          'step' => string 'NewUser' (length=7)
          'chat_id' => int 1016239559
          'Cash' => null
          'vip' => int 0
          'grade' => int 0
          'Download' => int 0
      2 => 
        array (size=7)
          'id' => int 19
          'step' => string 'NewUser' (length=7)
          'chat_id' => int -663757927
          'Cash' => null
          'vip' => int 0
          'grade' => int 0
          'Download' => int 0
select * from db

PHP

select('*','db');

SQL LIKE Examples

SELECT * FROM Customers
WHERE CustomerName LIKE 'a%';

PHP

This Update : 2.0

like('*','Customers',[
    'CustomerName'=>'a%'
]);

MIN() Example

SELECT MIN(Price) AS SmallestPrice
FROM Products;

PHP

select('MIN(Price) AS SmallestPrice','Products');

SQL INNER JOIN Example

This section will be updated later

SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;

PHP

select('Orders.OrderID, Customers.CustomerName','Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID');

SQL insert Example

sql :

insert into table (one,tow,there) values ('one','tow','there')

php :

insert('table',['one'=>'one','tow'=>'tow','there'=>'there']);

execute => 0 or 1 query insert('table',['one'=>'one','tow'=>'tow','there'=>'there']); :

insert into table (one,tow,there) values (?,?,?)

The content is then filled with prepare and bindValue

SQL delete data

deleted(string $table ,$where = "None",string $other = null);

SQL:

DELETE FROM one WHERE p = 12

PHP :

deleted('one',['p'=>12]);

SQL update Example

sql:

update tb set id = '12' where name = '14'

PHP :

update('tb',['id'=>12],['name'=>14]);

execute : 0 or 1 If execute is equal to 0, it means that the update has not been done

SQL Created New Table

table(string $table,$column);

sql :

CREATE TABLE accounts (
        id int
        );

php :

table('accounts',['id'=>'int']);

execute => 0 or 1

SQL Set unique column

unique(string $table,$column);

SQL :

ALTER TABLE articles
    ADD UNIQUE (slug)

php:

unique('articles',['slug']);

SQL Set primary Key

primary(string $table,$column);

SQL :

ALTER TABLE accounts
    ADD PRIMARY KEY (token);

php :

primary('accounts',['token']);

Drop Table & column Exsample

drop($table,array $columns = []);

SQL Drop column:

ALTER TABLE table
DROP COLUMN column;

PHP Drop column:

drop('table',['column']);

SQL Drop Table

DROP TABLE a,b;

PHP Drop Table :

drop(['a','b']);
You might also like...
A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.
A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the Binance API and allows you to easily communicate with it. Important Note This package is in early deve

Another initiative where patient in need of Blood and recovered patients willing to donate Blood can come together under one platform and connect with each other.
Another initiative where patient in need of Blood and recovered patients willing to donate Blood can come together under one platform and connect with each other.

This is yet another initiative where patient in need of Blood and recovered patients willing to donate Blood can come together under one platform and connect with each other.

MySQL parser for free-id/core package

MySQL parser Installation You can install the package via composer: composer require free-id/mysql Usage use FreeId\Mysql\Parser; $parser = new Parse

This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database.
This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database.

PHP basic template This example shows how to use Anychart library with the PHP programming language, Laravel framework and MySQL database. Running To

A forum software written in vanilla PHP with a MariaDB/MySQL database.

GloomyBB GloomyBB is a simple forum software written in vanilla PHP with a MariaDB/MySQL database. It is currently still in early development but is u

A project of a Login screen made in PHP/CSS3/HTML5/JS with MySQL database integration
A project of a Login screen made in PHP/CSS3/HTML5/JS with MySQL database integration

A project of a Login screen made in PHP/CSS3/HTML5/JS with MySQL database integration. And animations made with CSS3 and JavaScript itself! 😊

A web application built on PHP for user to view their credit information in their mysql database
A web application built on PHP for user to view their credit information in their mysql database

TheCreditInfo Table of Content About Inspiration Technologies Client Pages Usage About Credere is a website created to help you track your credit hist

QueryHandler - Handling PDO ' s query with mySQL database

QueryHandler this class's method are static .... that mean you don't need to create an object to use it . All methodes will return an Exception if it

TiDB is an open source distributed HTAP database compatible with the MySQL protocol
TiDB is an open source distributed HTAP database compatible with the MySQL protocol

What is TiDB? TiDB ("Ti" stands for Titanium) is an open-source NewSQL database that supports Hybrid Transactional and Analytical Processing (HTAP) wo

Owner
Ali
I'm Irani
Ali
For beginner programmers, a list of exercises.

Hacktoberfest 2021 Junte-se ao Hacktoberfest - Aqui! Support open source throughout October! Hacktoberfest incentiva a participação na comunidade de c

Igor Gomes 5 Oct 18, 2022
Here is the top 100 PHP functions: it is the list of the most often used PHP native functions

Here is the top 100 PHP functions: it is the list of the most often used PHP native functions. If you are a PHP developer, you must know the Top 100 PHP Functions deeply.

Max Base 16 Dec 11, 2022
Magento-Functions - A Resource of Magento Functions

Magento-Functions A Resource of Magento Functions Table of Contents Category Product User Cart Checkout General Account [Working w/ URL's] (#urls) Cat

Bryan Littlefield 28 Apr 19, 2021
A PHP MySQL database client class to simplify database access

This lightweight database class is written with PHP and uses the MySQLi extension, it uses prepared statements to properly secure your queries, no need to worry about SQL injection attacks.

Khader Handal 50 Jul 30, 2022
âš¡ Php snippets, random stuff, demos, functions, fast message system, agnostic and framework free - 100% compactible ;) âš¡

âš¡ Php8 FPM Nginx Fast, Scripts, Pearls & Treasures ?? Want to run and test asap ? docker-compose up -d phpgit_php8;ip=$(docker-machine ip default);ech

Benjamin FONTAINE 0 Mar 20, 2022
Connect Nios4 with Google Calendar via PHP

Nios4_Google_Calendar Connect Nios4 with Google Calendar via PHP ISTRUZIONI INTEGRAZIONE GOOGLE CALENDAR CON NIOS4. Guida per l'integrazione del calen

null 2 Sep 23, 2021
Free ZIP Code API - Free Access to Worldwide Postal Code Data

About Zipcodebase - Free Zip Code API Zipcodebase is a zip code API that was founded in 2019 to solve common issues with postal code data. As we have

SaaS Industries 2 Nov 26, 2022
It is an open-source and free project, which is faced with the drawing lovers, providing a free and simple Gallery service

It is an open-source and free project, which is faced with the drawing lovers, providing a free and simple Gallery service

WeepingDogel 5 Dec 15, 2022
jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages

jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages

null 19 Dec 27, 2022
Connect ThriveCart with FluentCRM

Fluent Connect Connect ThriveCart with FluentCRM & WordPress The aim of this plugin is to connect ThriveCart with FluentCRM. ThriveCart is a super sim

WPManageNinja 2 Jan 24, 2022