English 中文(简体)
MySQLi - Introduction
  • 时间:2024-09-17

MySQLi - Introduction


Previous Page Next Page  

MySQLi is an extension to MySQL API available in PHP and is introduced from PHP 5.0 onwards. It is also known as MySQL improved extension. Motivation behind MySQLi was to take advantage of new features available in MySQL 4.1.3 onwards. It provides numerous benefits over MySQL extension.

    MySQL provides an object oriented interface. It provides both object oriented and procedural approach to handle database operations.

Object Oriented Interface


<?php
   $mysqp = mysqp_connect("localhost", "user", "password", "database-name");

   $result = mysqp_query($mysqp, "SELECT  Welcome to MySQLi  AS _msg FROM DUAL");
   $row = mysqp_fetch_assoc($result);
   echo $row[ _msg ];
?>

Procedural Approach


<?php
   $mysqp = new mysqp("localhost", "user", "password", "database-name");

   $result = $mysqp→query("SELECT  Welcome to MySQLi  AS _msg FROM DUAL");
   $row = $result→fetch_assoc();
   echo $row[ _msg ];
?>

    MySQLi supports prepared statments.

    MySQLi supports multiple statments.

    MySQLi supports transactions.

    MySQLi provides enhanced debugging capabipties.

Advertisements