public function setID($id)
    {
        $dao = $this->getDAO();
        $pkey = $dao->getPrimaryKey();

        if (count($pkey) === 1 && is_scalar($id))
        {
            $pcol = reset($pkey);
            $this->setField($pcol->getName(), $id);
        }
        elseif (is_array($id) && array_keys($id) === array_keys($pkey))
        {
            foreach ($pkey as $name => $def)
            {
                $this->setField($name, $id[$name]);
            }
            $this->_id = $id;
        }
        else
        {
            throw new InvalidTypeException("Provided ID does not match primary key");
        }
        return $this;
    }
public function setID($id)
    {
        $dao = $this->getDAO();
        $pkey = $dao->getPrimaryKey();

        if (count($pkey) === 1 && is_scalar($id))
        {
            $pcol = reset($pkey);
            $this->setField($pcol->getName(), $id);
        }
        elseif (is_array($id) && array_keys($id) === array_keys($pkey))
        {
            foreach ($pkey as $name => $def)
            {
                $this->setField($name, $id[$name]);
            }
            $this->_id = $id;
        }
        else
        {
            throw new InvalidTypeException("Provided ID does not match primary key");
        }
        return $this;
    }
public function setID ( $ id ) { $ dao = $ this -> getDAO ( ) ; $ pkey = $ dao -> getPrimaryKey ( ) ; if ( count ( $ pkey ) === 1 && is_scalar ( $ id ) ) { $ pcol = reset ( $ pkey ) ; $ this -> setField ( $ pcol -> getName ( ) , $ id ) ; } elseif ( is_array ( $ id ) && array_keys ( $ id ) === array_keys ( $ pkey ) ) { foreach ( $ pkey as $ name => $ def ) { $ this -> setField ( $ name , $ id [ $ name ] ) ; } $ this -> _id = $ id ; } else { throw new InvalidTypeException ( "Provided ID does not match primary key" ) ; } return $ this ; }
Set the primary key of the model instance
@param mixed $id The primary key. Either a scalar value or an array for a combined primary key
@return Wedeto\DB\Model Provides fluent interface
Set the primary key of the model instance