Giter Site home page Giter Site logo

pdo_connecting_database's Introduction

Connecting to MySQL in PHP using PDO

Connecting to MySQL with PDO. it easy for you and secure for your company project

Installation

You have to edit "connect_me.php" Path: "app/config/connect_me.php"

/*** MYSQL HOSTNAME ***/
protected $db_host = "localhost"; // Put your Host name here...

/*** MYSQL DATABANSE NAME  ***/
protected $db_name = "test"; // Put your Database name here...

/*** MYSQL USERNAME ***/
protected $db_user = "irfanahmed";  // Put your MYSQL Username here

/*** MYSQL PASSWORD ***/
protected $db_pass = "***mikmikmik***";  // Put Your MYSQL Password here

require or include in your project page, where you need to connect your database.r.

define('ACCESS_ALLOW',true);
require('app/config/connect_me.php');

You can change define the text "ACCESS ALLOW" as you want. if you what to change the text. Search file path: "app/config/connect_me.php" in this file, you can change "defined('ACCESS_ALLOW')"

private static function Block_Access()
{ return (!defined('ACCESS_ALLOW')) ? true : false;  }

When you have changed it. !defined('ACCESS_ALLOW') to !defined('Something') you'll use with changes:

define('something',true);
require('app/config/connect_me.php');

it just block direct access file

How to use it

Create a class Object:

$pdo = new connect_me();

Database resource:

$this->conn   //Database handler queries
$q = $pdo->conn->prepare("SELECT * FROM `user`");    /** Example of query */

Basic Example

define('ACCESS_ALLOW',true);
require('app/config/connect_me.php');
    
$pdo = new connect_me();
$q = $pdo->conn->prepare("SELECT * FROM `user`");
$q->execute();
while($row = $q->fetch(PDO::FETCH_OBJ))
{
echo $row->user_name."<br>";
}

License MIT

pdo_connecting_database's People

Contributors

irfanghuori avatar

Stargazers

IQra Naz avatar  avatar Kashef Rao avatar

Watchers

 avatar

Forkers

kashef-hus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.