Skip to content

Instantly share code, notes, and snippets.

@c9s c9s/queryAPI.php
Created Apr 10, 2017

What would you like to do?
public function testRepoFetchColumn()
$this->assertResultSuccess(Book::create([ 'title' => 'Book 1' ]));
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
// create one book with duplicated title
$this->assertResultSuccess(Book::create([ 'title' => 'Book 2' ]));
$q = Book::masterRepo()->select('DISTINCT title');
$titles = $q->fetchColumn(0);
$this->assertCount(2, $titles);
foreach ($titles as $title) {
$this->assertStringMatchesFormat('Book %i', $title);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.