-
Notifications
You must be signed in to change notification settings - Fork 24
/
example-01.php
executable file
·30 lines (24 loc) · 925 Bytes
/
example-01.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
<?php
/**
* Issue SELECT command through adapter, using the driver and platform
* to create completely portable SQL by hand.
*
* Currently tested against:
* Mysqli via MySQL
* Sqlite via PDO
*/
/* @var $adapter Zend\Db\Adapter\Adapter */
$adapter = include ((file_exists('bootstrap.php')) ? 'bootstrap.php' : 'bootstrap.dist.php');
refresh_data($adapter);
// create completely portable SQL by hand
$sql = 'SELECT * FROM '
. $adapter->platform->quoteIdentifier('artist')
. ' WHERE ' . $adapter->platform->quoteIdentifier('id') . ' = ' . $adapter->driver->formatParameterName('id');
/* @var $statement \Zend\Db\Adapter\Driver\StatementInterface */
$statement = $adapter->query($sql);
$parameters = array('id' => 2);
/* @var $results Zend\Db\ResultSet\ResultSet */
$results = $statement->execute($parameters);
$row = $results->current();
$name = $row['name'];
assert_example_works($name == 'Linkin Park');