Skip to content

Commit

Permalink
Tweak sql examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rybakit committed Jun 8, 2023
1 parent 5e67da5 commit 6a74d2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions examples/protocol/execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
* It was introduced in Tarantool 2.11.0-rc1. If compat.sql_seq_scan_default set to "new"
* (default value since 3.0), query returns error when trying to scan without keyword.
*/
$seqScan = server_version_at_least('2.11.0-rc1', $client) ? 'SEQSCAN' : '';
$result3 = $client->executeQuery("SELECT * FROM $seqScan users WHERE \"email\" = ?", 'foo@example.com');
$scanQuery = server_version_at_least('2.11.0-rc1', $client)
? 'SELECT * FROM SEQSCAN users WHERE "email" = ?'
: 'SELECT * FROM users WHERE "email" = ?';
$result3 = $client->executeQuery($scanQuery, 'foo@example.com');

$result4 = $client->executeQuery('SELECT * FROM users WHERE "id" IN (?, ?)', 1, 2);

Expand Down
6 changes: 4 additions & 2 deletions examples/protocol/prepare.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
* It was introduced in Tarantool 2.11.0-rc1. If compat.sql_seq_scan_default set to "new"
* (default value since 3.0), query returns error when trying to scan without keyword.
*/
$seqScan = server_version_at_least('2.11.0-rc1', $client) ? 'SEQSCAN' : '';
$result = $client->executeQuery("SELECT COUNT(\"id\") AS \"cnt\" FROM $seqScan users");
$scanQuery = server_version_at_least('2.11.0-rc1', $client)
? 'SELECT COUNT("id") AS "cnt" FROM SEQSCAN users'
: 'SELECT COUNT("id") AS "cnt" FROM users';
$result = $client->executeQuery($scanQuery);

printf("Result: %s\n", json_encode($result[0]));

Expand Down

0 comments on commit 6a74d2e

Please sign in to comment.