Zend_CodeGenerator arrays as property

3 messages Options
Embed this post
Permalink
iceangel89

Zend_CodeGenerator arrays as property

Reply Threaded More More options
Print post
Permalink
i am trying to use Zend_CodeGenerator to generate my models from my MySQL db so far this is what i got ...

class My_blogentries
{
    protected $_primary = 'array('id')';
}

as u can see i cant have a array for the property ... and how can i add "extends Zend_Db_Table Abstract" also?
vince.

Re: Zend_CodeGenerator arrays as property

Reply Threaded More More options
Print post
Permalink
First what your trying to do is invalid this
protected $_primary = 'array('id')';

will cause a syntax error.

second why would you want to have a default value for a property to be a string that consists of an array? this will fail it you try to run it as if it was an array.

What are you trying to do exactly?



On Sun, May 24, 2009 at 6:41 PM, iceangel89 <[hidden email]> wrote:

i am trying to use Zend_CodeGenerator to generate my models from my MySQL db
so far this is what i got ...

class My_blogentries
{
   protected $_primary = 'array('id')';
}

as u can see i cant have a array for the property ... and how can i add
"extends Zend_Db_Table Abstract" also?
--
View this message in context: http://www.nabble.com/Zend_CodeGenerator-arrays-as-property-tp23694912p23694912.html
Sent from the Zend Framework mailing list archive at Nabble.com.




--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
Zend Framework Certified Engineer.
-- http://www.vadimg.co.il/



iceangel89

Re: Zend_CodeGenerator arrays as property

Reply Threaded More More options
Print post
Permalink
u know models have properties like

dependentTables thats an array? i want to create those ...

but i fixed it by modifying ZF core file to have 1 more property body and i set the default value to this body if its set... just a temp work around for now and it works! but let me know if theres a better method ...

    protected $_body = null;
    public function setBody($string) {
        $this->_body = $string;
    }
    public function generate()
    {
       ...
            $string = '    ' . $this->getVisibility() . ' $' . $name . ' = ' . ((null !== $defaultValue) ? '\'' . $defaultValue . '\'' : 'null') . ';';
            if ($this->_body) {
                $string = '    ' . $this->getVisibility() . ' $' . $name . ' = ' . $this->_body . ';';
            }

       ...
       return $string;
    }
vince. wrote:
First what your trying to do is invalid this
protected $_primary = 'array('id')';

will cause a syntax error.

second why would you want to have a default value for a property to be a
string that consists of an array? this will fail it you try to run it as if
it was an array.

What are you trying to do exactly?



On Sun, May 24, 2009 at 6:41 PM, iceangel89 <comet2005@gmail.com> wrote:

>
> i am trying to use Zend_CodeGenerator to generate my models from my MySQL
> db
> so far this is what i got ...
>
> class My_blogentries
> {
>    protected $_primary = 'array('id')';
> }
>
> as u can see i cant have a array for the property ... and how can i add
> "extends Zend_Db_Table Abstract" also?
> --
> View this message in context:
> http://www.nabble.com/Zend_CodeGenerator-arrays-as-property-tp23694912p23694912.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>


--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
Zend Framework Certified Engineer.
-- http://www.vadimg.co.il/