From fad7667930db46129701982d9b0e34263a64c9fa Mon Sep 17 00:00:00 2001 From: Christian Weber Date: Wed, 11 Jul 2012 13:19:34 +0000 Subject: implement static function get() as discussed --- it_dbi.class | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'it_dbi.class') diff --git a/it_dbi.class b/it_dbi.class index fbe9690..3281415 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -874,6 +874,17 @@ function valid() return (bool)$this->_data; } + +/** + * STATIC: create an object and read its record from DB. + * @param $id ID of record to read + * @return initialized object or null if ID not found + */ +static function get($id) +{ + return isset($id) && ($rec = new static) && $rec->read($id) ? $rec : null; +} + } /* End class it_dbi */ ?> -- cgit v1.2.3