-
Notifications
You must be signed in to change notification settings - Fork 24
/
example-04.php
36 lines (25 loc) · 1023 Bytes
/
example-04.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Issue DELETE command through adapter using array paramaterization (default)
*/
$adapter = include ((file_exists('bootstrap.php')) ? 'bootstrap.php' : 'bootstrap.dist.php');
refresh_data($adapter);
$qi = function($name) use ($adapter) { return $adapter->platform->quoteIdentifier($name); };
$fp = function($name) use ($adapter) { return $adapter->driver->formatParameterName($name); };
$sql = 'DELETE FROM ' . $qi('artist')
. ' WHERE ' . $qi('id') . ' = ' . $fp('id');
/* @var $statement Zend\Db\Adapter\DriverStatementInterface */
$statement = $adapter->query($sql);
$parameters = array(
'id' => 1
);
$statement->execute($parameters);
// DATA INSERTED, NOW CHECK
/* @var $statement Zend\Db\Adapter\DriverStatementInterface */
$statement = $adapter->query('SELECT * FROM '
. $qi('artist')
. ' WHERE id = ' . $fp('id'));
/* @var $results Zend\Db\ResultSet\ResultSet */
$results = $statement->execute(array('id' => 1));
$row = $results->current();
assert_example_works($row == false);