Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/4-update_1.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/4-update_1.php  >  Download  
File: examples/4-update_1.php
Role: Example script
Content type: text/plain
Description: Example 4
Class: PDO_MySQLi class
Access MySQL using PDO or MySQLi extensions
Author: By
Last change:
Date: 1 year ago
Size: 792 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);

// UPDATE with corresponding placeholder names in the SQL statement, and the values into an associative array
$sql "UPDATE `testclass` SET `title` = :title WHERE `url` = :url";
$vals = array('title'=>'JavaScript & jQuery''url'=>'http://coursesweb.net/javascript/');

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

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