protected function getPrimaryKeyPredicate($id)
    {
        if (!is_scalar($id) && !is_array($id)) {
            throw new Exception\InvalidArgumentException(__METHOD__ . ": Id must be scalar or array, type " . gettype($id) . " received");
        }
        $keys = $this->getPrimaryKeys();
        if (count($keys) == 1) {
            $pk = $keys[0];
            if (!is_scalar($id)) {
                $type = gettype($id);
                throw new Exception\InvalidArgumentException(__METHOD__ . ": invalid primary key value. Table '{$this->table}' has a single primary key '$pk'. Argument must be scalar, '$type' given");
            }
            $predicate = [$pk => $id];
        } else {
            if (!is_array($id)) {
                $pks = implode(',', $keys);
                $type = gettype($id);
                throw new Exception\InvalidArgumentException(__METHOD__ . ": invalid primary key value. Table '{$this->table}' has multiple primary keys '$pks'. Argument must be an array, '$type' given");
            }

            $matched_keys = array_diff($id, $keys);
            if (count($matched_keys) == count($keys)) {
                $predicate = $matched_keys;
            } else {
                $pks = implode(',', $keys);
                $vals = implode(',', $matched_keys);
                throw new Exception\InvalidArgumentException(__METHOD__ . ": incomplete primary key value. Table '{$this->table}' has multiple primary keys '$pks', values received '$vals'");
            }
        }
        return $predicate;
    }
protected function getPrimaryKeyPredicate($id)
    {
        if (!is_scalar($id) && !is_array($id)) {
            throw new Exception\InvalidArgumentException(__METHOD__ . ": Id must be scalar or array, type " . gettype($id) . " received");
        }
        $keys = $this->getPrimaryKeys();
        if (count($keys) == 1) {
            $pk = $keys[0];
            if (!is_scalar($id)) {
                $type = gettype($id);
                throw new Exception\InvalidArgumentException(__METHOD__ . ": invalid primary key value. Table '{$this->table}' has a single primary key '$pk'. Argument must be scalar, '$type' given");
            }
            $predicate = [$pk => $id];
        } else {
            if (!is_array($id)) {
                $pks = implode(',', $keys);
                $type = gettype($id);
                throw new Exception\InvalidArgumentException(__METHOD__ . ": invalid primary key value. Table '{$this->table}' has multiple primary keys '$pks'. Argument must be an array, '$type' given");
            }

            $matched_keys = array_diff($id, $keys);
            if (count($matched_keys) == count($keys)) {
                $predicate = $matched_keys;
            } else {
                $pks = implode(',', $keys);
                $vals = implode(',', $matched_keys);
                throw new Exception\InvalidArgumentException(__METHOD__ . ": incomplete primary key value. Table '{$this->table}' has multiple primary keys '$pks', values received '$vals'");
            }
        }
        return $predicate;
    }
protected function getPrimaryKeyPredicate ( $ id ) { if ( ! is_scalar ( $ id ) && ! is_array ( $ id ) ) { throw new Exception \ InvalidArgumentException ( __METHOD__ . ": Id must be scalar or array, type " . gettype ( $ id ) . " received" ) ; } $ keys = $ this -> getPrimaryKeys ( ) ; if ( count ( $ keys ) == 1 ) { $ pk = $ keys [ 0 ] ; if ( ! is_scalar ( $ id ) ) { $ type = gettype ( $ id ) ; throw new Exception \ InvalidArgumentException ( __METHOD__ . ": invalid primary key value. Table '{$this->table}' has a single primary key '$pk'. Argument must be scalar, '$type' given" ) ; } $ predicate = [ $ pk => $ id ] ; } else { if ( ! is_array ( $ id ) ) { $ pks = implode ( ',' , $ keys ) ; $ type = gettype ( $ id ) ; throw new Exception \ InvalidArgumentException ( __METHOD__ . ": invalid primary key value. Table '{$this->table}' has multiple primary keys '$pks'. Argument must be an array, '$type' given" ) ; } $ matched_keys = array_diff ( $ id , $ keys ) ; if ( count ( $ matched_keys ) == count ( $ keys ) ) { $ predicate = $ matched_keys ; } else { $ pks = implode ( ',' , $ keys ) ; $ vals = implode ( ',' , $ matched_keys ) ; throw new Exception \ InvalidArgumentException ( __METHOD__ . ": incomplete primary key value. Table '{$this->table}' has multiple primary keys '$pks', values received '$vals'" ) ; } } return $ predicate ; }
Return primary key predicate

@param integer|string|array $id

@throws Exception\InvalidArgumentException
@throws Exception\PrimaryKeyNotFoundException
@return array predicate
Return primary key predicate