src/AbstractModel.php
public function findByPK()
    {
        $pk = func_get_args();
        if (!$this->_properties['primary_key'] || !$pk)
            throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);

        !is_array(reset($pk)) || $pk = array_shift($pk);
        $criteria = $values = array();
        foreach ($this->_properties['primary_key'] as $field) {
            $token = ':pk_'.$field;
            $criteria[] = '{table}.'.$field.'='.$token;
            $values[$token] = isset($pk[$field])?$pk[$field]:array_shift($pk);
        }

        return $this->limit(1)->find(implode(' and ', $criteria), $values);
    }
public function findByPK()
    {
        $pk = func_get_args();
        if (!$this->_properties['primary_key'] || !$pk)
            throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);

        !is_array(reset($pk)) || $pk = array_shift($pk);
        $criteria = $values = array();
        foreach ($this->_properties['primary_key'] as $field) {
            $token = ':pk_'.$field;
            $criteria[] = '{table}.'.$field.'='.$token;
            $values[$token] = isset($pk[$field])?$pk[$field]:array_shift($pk);
        }

        return $this->limit(1)->find(implode(' and ', $criteria), $values);
    }
public function findByPK ( ) { $ pk = func_get_args ( ) ; if ( ! $ this -> _properties [ 'primary_key' ] || ! $ pk ) throw new Exception ( sprintf ( self :: E_PrimaryKey , get_called_class ( ) ) , 1 ) ; ! is_array ( reset ( $ pk ) ) || $ pk = array_shift ( $ pk ) ; $ criteria = $ values = array ( ) ; foreach ( $ this -> _properties [ 'primary_key' ] as $ field ) { $ token = ':pk_' . $ field ; $ criteria [ ] = '{table}.' . $ field . '=' . $ token ; $ values [ $ token ] = isset ( $ pk [ $ field ] ) ? $ pk [ $ field ] : array_shift ( $ pk ) ; } return $ this -> limit ( 1 ) -> find ( implode ( ' and ' , $ criteria ) , $ values ) ; }
Find by PK
Find by PK