try midgard_article, catch midgard_exception

Posted on 2007-02-27 22:56:50 EET.

What I focus on recently is midgard-core and midgard-php extension. I try to make both usable as soon as possible. Completely "forgotten" midgard-apache module must wait till Midgard core has more power. And midgard-data... I will write about it later , looks like many parts of midgard-data will be moved to core :)

Reading ZE2 sources and asking "too many" questions at pecl developers mailing list let me refactor midgard-php extension and implement it almost from scratch with new ( I must say , quite good! ) zend objects store functionality.

For the first time I felt that doing something with zend sources really does make sense ;)

What does it really mean?

  • when you read php object property ( like echo $obj->prop ) you really read core's GObject property. So let's say you want to be smarter than core and want to "force" guid property value. No way, in such case core will produce warning which is propagated as php warning message ( but this is already known from 1.8 series )

  • when you set value as php object property ( like $obj->prop = "abc" ) you really set core's GObject property

  • when you destroy php object , you destroy core's GObject

  • no more weird __res properties with even more weird integers which points to something or anything

For the first time I can say - this is language bindings.

And something completely new in midgard-php extension for pure OOP fanatics:

try{
    $ma = new my_article();
    $ma->get_by_id(1000000); 
} catch (midgard_exception $me) {
    echo "Couldn't get object by id. The reason is: ".$me->getMessage()." \n";
}

Message well known from mgd_errstr function is set as exception message, so what you expect here is:

Couldn't get object by id. The reason is: Object does not exist.

I just do not have article record identified by 1000000.

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS