public static function firstOrNew($id)
    {
        if ($entity = self::getDataMapperInstance()->first($id)) {
            return $entity;
        }

        $entity = new static();
        $entity->_id = $id;

        return $entity;
    }
public static function firstOrNew($id)
    {
        if ($entity = self::getDataMapperInstance()->first($id)) {
            return $entity;
        }

        $entity = new static();
        $entity->_id = $id;

        return $entity;
    }
public static function firstOrNew ( $ id ) { if ( $ entity = self :: getDataMapperInstance ( ) -> first ( $ id ) ) { return $ entity ; } $ entity = new static ( ) ; $ entity -> _id = $ id ; return $ entity ; }
Gets the first entity of this kind that matches the query. If no
document was found, a new entity will be returned with the
_if field filled.

@param mixed $id document id

@return ActiveRecord
Gets the first entity of this kind that matches the query . If no document was found a new entity will be returned with the _if field filled .