Jump to: navigation, search

PHP ADODB Update with place holder

From w3cyberlearnings

Contents

PHP ADODB Update Multiple Records

Use question mark place holder and update records.

Syntax ADODB UPDATE Record


$sql = "UPDATE user_infor SET email=? WHERE id=?";
$conn1->Execute($sql, array('email',2));

Example 1

<?php

include 'adodb5/adodb.inc.php';

$host = 'localhost';
$user = 'user2000';
$pass = 'password2000';
$dbname = 'w3cyberlearning';

$conn1 = &ADONewConnection('mysql');
$conn1->PConnect($host, $user, $pass, $dbname);

$sql = "UPDATE user_infor SET email=? WHERE id=?";

$my_data = array(
	 array('[email protected]',1),
	 array('[email protected]',2),
	 array('[email protected]',3),
	 array('[email protected]',4)
);

for ($i = 0; $i < count($my_data); $i++) {
	$d = $conn1->Execute($sql, $my_data[$i]);
	if (!$d) {
		print 'error' . $conn1->ErrorMsg() . '<br>';
	}
	else {
		echo 'Success! Update';
		echo "<br/>";
	}
}

?>

Related Links


Navigation
Web
SQL
MISC
References