Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/8-delete.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of MarPlo  >  PDO_MySQLi class  >  examples/8-delete.php  >  Download  
File: examples/8-delete.php
Role: Example script
Content type: text/plain
Description: Example 8
Class: PDO_MySQLi class
Access MySQL using PDO or MySQLi extensions
Author: By
Last change:
Date: 2013-09-04 02:11
Size: 671 bytes
 

Contents

Class file image Download
<?php
// includes the file that contains data for connecting to mysql database, and  PDO_MySQLi class
include('../conn_mysql.php');

// creates object with connection to MySQL
$conn = new PDO_MySQLi($mysql);

// DELETE with named placeholder and associated value added into an array
$sql "DELETE FROM `testclass` WHERE `id` < :id";
$vals = array('id'=>3);

// executes the SQL query, passing the SQL query and the array with value
$resql $conn->sqlExecute($sql$vals);

// check if the SQL query succesfully performed, displays the number of affected rows
if($resql) echo 'Deleted succesfully '$conn->affected_rows .' rows';
else echo 
$conn->error;