Most of the PHP developers using Mysql or Mysqli php functions when they work with databases. but PHP has introduced new extension call PDO in PHP 5.1. this methord is way better and very productive. PDO is stands for PHP Data Objects.
Note : Mysql functions is removed from PHP 5.5. so its better to use PDO or Mysqi. I strongly recommend to use PDO.
PDO Supported Databases Drivers List
You can use bellow code to find which driver is installed on your system.
print_r(PDO::getAvailableDrivers());
- PDO_DBLIB ( FreeTDS / Microsoft SQL Server / Sybase )
- PDO_FIREBIRD ( Firebird/Interbase 6 )
- PDO_IBM ( IBM DB2 )
- PDO_INFORMIX ( IBM Informix Dynamic Server )
- PDO_MYSQL ( MySQL 3.x/4.x/5.x )
- PDO_OCI ( Oracle Call Interface )
- PDO_ODBC ( ODBC v3 (IBM DB2, unixODBC and win32 ODBC) )
- PDO_PGSQL ( PostgreSQL )
- PDO_SQLITE ( SQLite 3 and SQLite 2 )
- PDO_4D ( 4D )
Lets Connect to the database using PDO
Note : Different database drivers may have different connection methods. i am not going to all of them i will just explain how to connect with most common databases.
Connect Mysql using PDO_Mysql
$user = "root"; $pass=""; $host="localhost"; $dbname="my_db"; try { $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass); } catch(PDOexception $e) { echo $e->getMassage(); }
Connect Ms Sql Server Using PDO
$user = "root"; $pass=""; $host="localhost"; $dbname="my_db"; try { $DBH = new PDO("mssql:host=$host;dbname=$dbname", $user, $pass); } catch(PDOexception $e) { echo $e->getMassage(); }
Connect Sybase using PDO
$user = "root"; $pass=""; $host="localhost"; $dbname="my_db"; try { $DBH = new PDO("mybase:host=$host;dbname=$dbname", $user, $pass); } catch(PDOexception $e) { echo $e->getMassage(); }
Connect SQLite using PDO
try { $DBH = new PDO("sqlite:my/database/path/database.db"); } catch(PDOexception $e) { echo $e->getMassage(); }
Close PDO Connection
$DBH = null;
Ankara
ReplyDeleteBolu
Sakarya
Mersin
Malatya
85BGSY
0020B
ReplyDeleteBitmart Güvenilir mi
Nevşehir Şehir İçi Nakliyat
Ankara Boya Ustası
Iğdır Evden Eve Nakliyat
Maraş Şehir İçi Nakliyat
Erzincan Şehirler Arası Nakliyat
Mexc Güvenilir mi
Çerkezköy Korkuluk
Yozgat Şehir İçi Nakliyat
E50C3
ReplyDeleteKars Şehir İçi Nakliyat
Kırklareli Parça Eşya Taşıma
Antalya Lojistik
Satoshi Coin Hangi Borsada
Star Atlas Coin Hangi Borsada
Burdur Parça Eşya Taşıma
Çerkezköy Çamaşır Makinesi Tamircisi
Nevşehir Parça Eşya Taşıma
Adıyaman Lojistik
7BB70
ReplyDeleteBitcoin Kazma Siteleri
Binance Komisyon Ne Kadar
Coin Nasıl Kazılır
Binance Kaldıraç Var mı
Coin Kazanma
Bitcoin Kazanma Siteleri
Coin Kazanma
Bulut Madenciliği Nedir
Gate io Borsası Güvenilir mi