```php
<?php
-$statement = \wcf\system\WCF::getDB()->prepareStatement("SELECT * FROM wcf".WCF_N."_example");
+$statement = \wcf\system\WCF::getDB()->prepare("SELECT * FROM wcf1_example");
$statement->execute();
while ($row = $statement->fetchArray()) {
// handle result
```php
<?php
$sql = "SELECT *
- FROM wcf".WCF_N."_example
+ FROM wcf1_example
WHERE exampleID = ?
OR bar IN (?, ?, ?, ?, ?)";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
$statement->execute([
$exampleID,
$list, $of, $values, $for, $bar
```php
<?php
$sql = "SELECT *
- FROM wcf".WCF_N."_example
+ FROM wcf1_example
WHERE exampleID = ?";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql, 1);
+$statement = \wcf\system\WCF::getDB()->prepare($sql, 1);
$statement->execute([$exampleID]);
$row = $statement->fetchSingleRow();
```
There are two distinct differences when comparing with the example on query parameters above:
-1. The method `prepareStatement()` receives a secondary parameter that will be appended to the query as `LIMIT 1`.
+1. The method `prepare()` receives a secondary parameter that will be appended to the query as `LIMIT 1`.
2. Data is read using `fetchSingleRow()` instead of `fetchArray()` or similar methods, that will read one result and close the cursor.
### Fetch by Column
```php
<?php
$sql = "SELECT bar
- FROM wcf".WCF_N."_example";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+ FROM wcf1_example";
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
$statement->execute();
while ($bar = $statement->fetchColumn()) {
// handle result
```php
<?php
$sql = "SELECT bar
- FROM wcf".WCF_N."_example
+ FROM wcf1_example
WHERE exampleID = ?";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql, 1);
+$statement = \wcf\system\WCF::getDB()->prepare($sql, 1);
$statement->execute([$exampleID]);
$bar = $statement->fetchSingleColumn();
```
```php
<?php
$sql = "SELECT *
- FROM wcf".WCF_N."_example";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+ FROM wcf1_example";
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
$statement->execute();
$rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
```
```php
<?php
$sql = "SELECT exampleID
- FROM wcf".WCF_N."_example";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+ FROM wcf1_example";
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
$statement->execute();
$exampleIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
```
```php
<?php
$sql = "SELECT exampleID, userID
- FROM wcf".WCF_N."_example_mapping";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+ FROM wcf1_example_mapping";
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
$statement->execute();
$map = $statement->fetchMap('exampleID', 'userID');
```
```php
<?php
$sql = "SELECT exampleID, userID
- FROM wcf".WCF_N."_example_mapping";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+ FROM wcf1_example_mapping";
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
$statement->execute();
$map = $statement->fetchMap('exampleID', 'userID', false);
```
<?php
$data = ['abc', 'def', 'ghi'];
-$sql = "INSERT INTO wcf".WCF_N."_example
+$sql = "INSERT INTO wcf1_example
(bar)
VALUES (?)";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
\wcf\system\WCF::getDB()->beginTransaction();
foreach ($data as $bar) {
4 => 'ghi'
];
-$sql = "UPDATE wcf".WCF_N."_example
+$sql = "UPDATE wcf1_example
SET bar = ?
WHERE exampleID = ?";
-$statement = \wcf\system\WCF::getDB()->prepareStatement($sql);
+$statement = \wcf\system\WCF::getDB()->prepare($sql);
\wcf\system\WCF::getDB()->beginTransaction();
foreach ($data as $exampleID => $bar) {