2009年8月4日星期二

RE: [fw-db] Creating an instance of database table

As described in Rob Allen's tutorial you can initialize Autoload in your
bootstrap file as follows

Class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
Protected function _initAutoload()
{
$moduleLoader = new
Zend_Application_Module_Autoloader(array(
'namespace'=>'',
'basePath'=>APPLICATION_PATH));
Return $moduleLoader;

}

Then you are good to go...

Erdal YAZICIOGLU
Field Project Engineer Manager
Shell GTL Pearl Project
Page Europa S.R.L
Doha-Qatar
Unix is very simple, but it takes a genius to understand the simplicity.
(Dennis Ritchie)
www.erdalyazicioglu.com.tr

-----Original Message-----
From: Michael Hernandez [mailto:sequethin@gmail.com]
Sent: Monday, August 03, 2009 9:20 PM
To: ashoms0a
Cc: fw-db@lists.zend.com
Subject: Re: [fw-db] Creating an instance of database table

On Mon, 2009-08-03 at 11:03 -0700, ashoms0a wrote:

>
> But I am getting the below message and i don't know why:
>
> Fatal error: Class 'Category' not found in
> C:\wamp\www\eGal\application\controllers\CatController.php on line 21
>
> any help is highly appreciated
>

Based on the error you show here I'd say that you do not have your
autoloader configured in such a way that it can find your Category file.
Classes can only be autoloaded if you have the autoloader configured
properly.

For example something like this in your application's bootstrap would
register a new namespace for you:

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('My_');

Then you might have a class named My_Category in a file
named /path/to/your/library/My/Category.php

Which would look something like

class My_Category
{

}

Then you could access that class via

$cat = new My_Category();

And the autoloader would know, since you registered the "My" namespace
that it should look in the "My" directory for classes that are prefixed
with My_ similar to how it knows to look in the Zend folder for classes
prefixed with Zend_

Your problem isn't so much with Zend_Db, rather it seems you are missing
some details of your application configuration?

--Mike H

没有评论: