2009年4月28日星期二

Re: [fw-db] ZF1.8 - Best way of init db and creating models

Hey,

That's because your using the 'New' keywork when calling a static method.

class Bootstrap extends Zend_Application_Bootstrap_
Bootstrap
{
   public function init() {
       $db = Zend_Db::factory("PDO_MYSQL", array(
          "host"       => "localhost",
          "username"   => "root",
          "password"   => "",
          "dbname"     => "zf-ims"
       ));
   }

}

Just remove the 'New' in front of the Zend_Db

Vince.


On Tue, Apr 28, 2009 at 12:00 PM, iceangel89 <comet2005@gmail.com> wrote:

but its not for ZF1.8 where the bootstrapping is abit different

i tried:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
   public function init() {
       $db = new Zend_Db::factory("PDO_MYSQL", array(
          "host"       => "localhost",
          "username"   => "root",
          "password"   => "",
          "dbname"     => "zf-ims"
       ));
   }

}

but got:

Parse error: parse error, expecting `T_VARIABLE' or `'$'' in
D:\JiewMeng\sites\zf-ims\application\Bootstrap.php on line 6

line 6 is the $db = ... line


vince. wrote:
>
> Hey,
>
> Did you read the quick start guide? It's a great place to start from.
>
> Vince.
>
> On Tue, Apr 28, 2009 at 11:30 AM, iceangel89 <comet2005@gmail.com> wrote:
>
>>
>> whats the best way of initializing Zend_Db (bootstrapping etc) and
>> creating
>> models? i am new to ZF and using Zend Framework 1.8 from SVN. have used
>> Zend_Tool to generate my basic app structure already
>> --
>> View this message in context:
>> http://www.nabble.com/ZF1.8---Best-way-of-init-db-and-creating-models-tp23272556p23272556.html
>> Sent from the Zend DB mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Vincent Gabriel.
> Lead Developer, Senior Support.
> Zend Certified Engineer.
> Zend Framework Certified Engineer.
> -- http://www.vadimg.co.il/
>
>

--
View this message in context: http://www.nabble.com/ZF1.8---Best-way-of-init-db-and-creating-models-tp23272556p23273060.html
Sent from the Zend DB mailing list archive at Nabble.com.




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



没有评论: