We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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