src/Soluble/Normalist/Synthetic/Table.php
public function findOneBy($predicate, $combination = Predicate\PredicateSet::OP_AND)
    {
        $select = $this->select($this->table);

        try {
            $select->where($predicate, $combination);
        } catch (\Zend\Db\Sql\Exception\InvalidArgumentException $e) {
            $message = "Invalid predicates or combination detected (" . $e->getMessage() . ")";
            throw new Exception\InvalidArgumentException(__METHOD__ . ": $message");
        }

        try {
            $results = $select->execute()
                              ->toArray();
        } catch (\Exception $e) {
            $messages = [];
            $ex = $e;
            do {
                $messages[] = $ex->getMessage();
            } while ($ex = $ex->getPrevious());
            $message = implode(', ', array_unique($messages));

            $lmsg = '[' . get_class($e) . '] ' . strtolower($message) . '(code:' . $e->getCode() . ')';

            if (strpos($lmsg, 'column not found') !== false ||
                    strpos($lmsg, 'unknown column') !== false) {
                //"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'media_id' in 'where clause
                $rex = new Exception\ColumnNotFoundException(__METHOD__ . ": $message");
                throw $rex;
            } else {
                $sql_string = $select->getSqlString($this->sql->getAdapter()->getPlatform());
                $iqex = new Exception\InvalidArgumentException(__METHOD__ . ": $message - $sql_string");
                throw $iqex;
            }
        }

        if (count($results) == 0) {
            return false;
        }
        if (count($results) > 1) {
            throw new Exception\MultipleMatchesException(__METHOD__ . ": return more than one record");
        }

        $record = $this->record($results[0]);
        $record->setState(Record::STATE_CLEAN);
        return $record;
    }
public function findOneBy($predicate, $combination = Predicate\PredicateSet::OP_AND)
    {
        $select = $this->select($this->table);

        try {
            $select->where($predicate, $combination);
        } catch (\Zend\Db\Sql\Exception\InvalidArgumentException $e) {
            $message = "Invalid predicates or combination detected (" . $e->getMessage() . ")";
            throw new Exception\InvalidArgumentException(__METHOD__ . ": $message");
        }

        try {
            $results = $select->execute()
                              ->toArray();
        } catch (\Exception $e) {
            $messages = [];
            $ex = $e;
            do {
                $messages[] = $ex->getMessage();
            } while ($ex = $ex->getPrevious());
            $message = implode(', ', array_unique($messages));

            $lmsg = '[' . get_class($e) . '] ' . strtolower($message) . '(code:' . $e->getCode() . ')';

            if (strpos($lmsg, 'column not found') !== false ||
                    strpos($lmsg, 'unknown column') !== false) {
                //"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'media_id' in 'where clause
                $rex = new Exception\ColumnNotFoundException(__METHOD__ . ": $message");
                throw $rex;
            } else {
                $sql_string = $select->getSqlString($this->sql->getAdapter()->getPlatform());
                $iqex = new Exception\InvalidArgumentException(__METHOD__ . ": $message - $sql_string");
                throw $iqex;
            }
        }

        if (count($results) == 0) {
            return false;
        }
        if (count($results) > 1) {
            throw new Exception\MultipleMatchesException(__METHOD__ . ": return more than one record");
        }

        $record = $this->record($results[0]);
        $record->setState(Record::STATE_CLEAN);
        return $record;
    }
Find a record by unique key

@param  Where|\Closure|string|array|Predicate\PredicateInterface $predicate
@param  string $combination One of the OP_* constants from Predicate\PredicateSet

@throws Exception\ColumnNotFoundException when a column in the predicate does not exists
@throws Exception\MultipleMatchesException when more than one record match the predicate
@throws Exception\InvalidArgumentException when the predicate is not correct / invalid column
@throws \Zend\Db\Sql\Exception\InvalidArgumentException

@return Record|false