Jim Lucas wrote:
admin wrote:
OK, here we go: Propel in Symfony uses generated model classes
representing DB rows, stub classes inheriting from them ready to be used
(such as below), and accessors representing data columns:

[snipped]
This is a little different then what you are trying above, but maybe it is close to what you are looking for:

<?php
class FooPeer {
    function BAR() {
        return 'BAR';
    }
    function BAZ() {
        return 'BAZ';
    }
    function XYZZY() {
        return 'XYZZY';
    }
}
class BaseFoo {
        function setBar($value) {
                echo "BaseFoo::setBar({$value});\n";
        }

        function setBaz($value) {
                echo "BaseFoo::setBaz({$value});\n";
        }

        function setXyzzy($value) {
                echo "BaseFoo::setXyzzy({$value});\n";
        }

}
class Foo extends BaseFoo {
        function setBar($value) {
                $this->doSetColumn(FooPeer::BAR(), $value, __FUNCTION__);
        }

        function setBaz($value) {
                $this->doSetColumn(FooPeer::BAZ(), $value, __FUNCTION__);
        }

        function setXyzzy($value) {
                $this->doSetColumn(FooPeer::XYZZY(), $value, __FUNCTION__);
        }

        function doSetColumn($colname, $value, $col_mutator) {
                parent::$col_mutator($value);
        }
}

$Foo = new Foo();
echo "<pre>";
$Foo->setBar('my value for bar');
$Foo->setBaz('my value for baz');
$Foo->setXyzzy('my value for xyzzy');


Now will you mentally copy and paste the above code several times, doing the necessary text substitutions, what will you get? Three identical copies of doSetColumn() in each class! And the real doSetColumn() is a bit heavier than a one-liner. We come full circle.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to