Skip to content

Commit

Permalink
Added named parameter feature test for ':name' parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenick committed Feb 4, 2016
1 parent 4084595 commit 8a11a6a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions features/simple_statements.feature
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,58 @@ Feature: Simple Statements
"""
Mick Jager: Memo From Turner / Performance
"""

@cassandra-version-2.1
Scenario: Simple statements also supports ":name" arguments
Given the following example:
"""php
<?php
$cluster = Cassandra::cluster()
->withContactPoints('127.0.0.1')
->build();
$session = $cluster->connect("simplex");
$statement = new Cassandra\SimpleStatement(
"INSERT INTO playlists (id, song_id, artist, title, album) " .
"VALUES (62c36092-82a1-3a00-93d1-46196ee77204, ?, ?, ?, ?)"
);
$songs = array(
array(
'song_id' => new Cassandra\Uuid('756716f7-2e54-4715-9f00-91dcbea6cf50'),
'artist' => 'Joséphine Baker',
'title' => 'La Petite Tonkinoise',
'album' => 'Bye Bye Blackbird'
),
);
foreach ($songs as $song) {
$options = new Cassandra\ExecutionOptions(array('arguments' => $song));
$session->execute($statement, $options);
}
$statement = new Cassandra\SimpleStatement(
"SELECT * FROM simplex.playlists " .
"WHERE id = :id AND artist = :artist AND title = :title AND album = :album"
);
$options = new Cassandra\ExecutionOptions(
array('arguments' =>
array(
'id' => new Cassandra\Uuid('62c36092-82a1-3a00-93d1-46196ee77204'),
'artist' => 'Joséphine Baker',
'title' => 'La Petite Tonkinoise',
'album' => 'Bye Bye Blackbird'
)
)
);
$result = $session->execute($statement, $options);
$row = $result->first();
echo $row['artist'] . ": " . $row['title'] . " / " . $row['album'] . "\n";
"""
When it is executed
Then its output should contain:
"""
Joséphine Baker: La Petite Tonkinoise / Bye Bye Blackbird
"""

0 comments on commit 8a11a6a

Please sign in to comment.