PHP, MySQL 연동
PHP, MySQL 연동
글. 수알치 오상문
PHP는 MySQL을 조작하는 함수를 제공한다. 이 MySQL 함수를 사용하여 PHP 스크립트에서 MySQL 관련 작업을 수행할 수 있다.
1. PHP 5.5.0 이전
MySQL 데이터베이스에 연결하기 위해 MySQL extension API를 사용한다.
- MySQL extension API
mysql_로 시작하는 함수를 사용하여 MySQL 데이터베이스를 관리할 수 있다.
[참고] MySQL extension API 레퍼런스 사이트
http://docs.php.net/manual/kr/book.mysql.php
PHP: MySQL (Original) - Manual
There are no user contributed notes for this page.
docs.php.net
2. PHP 5.5.0 이상
다음과 같은 API를 이용하여 MySQL 관련 작업을 수행할 수 있다.
(MySQL 4.1.13 이상, 5.0.7 이상)
- MySQL improved extension(MySQLi extension)
- PHP Data Objects(PDO)
위 두 API는 장단점이 있지만 성능상 큰 차이는 없다. 다만, MySQLi는 객체 기반(object-oriented)과 절차식 형식(procedural)을 모두 사용할 수 있다.
[참고] MySQLi 레퍼런스 사이트
http://docs.php.net/manual/kr/book.mysqli.php
PHP: MySQLi - Manual
docs.php.net
[참고] PDO 레퍼런스 사이트
http://docs.php.net/manual/kr/book.pdo.php
PHP: PDO - Manual
I wanted to extend PDO class to store statistics of DB usage, and I faced some problems. I wanted to count number of created statements and number of their executings. So PDOStatement should have link to PDO that created it and stores the statistical info.
docs.php.net