Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Findfirst with just column names

Does findFirst() fetch data if a comma separated list of columns are given which form the primary key for the underlying table in exactly the same order. If pkcol1, pkcol2, pkcol3 are three columns which form the primary key of "finyear" table. This doesn't seem to work:

$pkcol1 = someVal;
$pkcol2 = anotherVal;
$pkcol3 = thirdVal;
$finyear = FinYear::findFirst($pkcol1, $pkcol2, $pkcol3);

I read in documentation that if we pass Primary Key value(s) to this function, it can fetch data. See below text from documentation:

You could find a certain record by its primary key and then print its name:

use Store\Toys\Robots;

// Find record with id = 3
$robot = Robots::findFirst(3);

Does this work with multi-column primary key?

edited Jul '18

You need to do it like this:

$pkcol[] = someVal;
$pkcol[] = anotherVal;
$pkcol[] = thirdVal;
$finyears = FinYear::find([
    "primary_key_column IN ({pkcols:array})",
    "bind" => [
        "pkcols" => $pkcol