<?php
function pdo() {
$stmt = $pdo->prepare('SELECT * FROM employees WHERE name = :name');
$stmt->execute(array('name' => $name)); foreach ($stmt as $row) {
// do something with $row
}
}
function mysqli() {
$stmt = $dbConnection->prepare('SELECT * FROM employees WHERE name = ?');
$stmt->bind_param('s', $name);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// do something with $row
}
}
PD9waHAKCmZ1bmN0aW9uIHBkbygpIHsKCSRzdG10ID0gJHBkby0+cHJlcGFyZSgnU0VMRUNUICogRlJPTSBlbXBsb3llZXMgV0hFUkUgbmFtZSA9IDpuYW1lJyk7Cgkkc3RtdC0+ZXhlY3V0ZShhcnJheSgnbmFtZScgPT4gJG5hbWUpKTsKCWZvcmVhY2ggKCRzdG10IGFzICRyb3cpIHsKCS8vIGRvIHNvbWV0aGluZyB3aXRoICRyb3cKCX0KfQpmdW5jdGlvbiBteXNxbGkoKSB7Cgkkc3RtdCA9ICRkYkNvbm5lY3Rpb24tPnByZXBhcmUoJ1NFTEVDVCAqIEZST00gZW1wbG95ZWVzIFdIRVJFIG5hbWUgPSA/Jyk7Cgkkc3RtdC0+YmluZF9wYXJhbSgncycsICRuYW1lKTsKCSRzdG10LT5leGVjdXRlKCk7CgkkcmVzdWx0ID0gJHN0bXQtPmdldF9yZXN1bHQoKTsKCXdoaWxlICgkcm93ID0gJHJlc3VsdC0+ZmV0Y2hfYXNzb2MoKSkgewoJLy8gZG8gc29tZXRoaW5nIHdpdGggJHJvdwoJfQp9