views:

122

answers:

1

I'm using Doctrine with Zend Framework. For my model, I'm using a base class, the regular class (which extends the base class), and a table class.

In my table class, I've created a method which does a query for records with a specific value for one of the fields in my model. When I try and call this method from my controller, I get an error message saying, "Message: Unknown method Doctrine_Table::getCreditPurchases". Is there something else I need to do to call functions in my table class? Here is my code:

class Model_CreditTable extends Doctrine_Table
{
    /**
     * Returns an instance of this class.
     *
     * @return object Model_CreditTable
     */
    public static function getInstance()
    {
        return Doctrine_Core::getTable('Model_Credit');
    }

    public function getCreditPurchases($id)
    {
        $q = $this->createQuery('c')
            ->where('c.buyer_id = ?', $id);

        return $q->fetchArray();
    }
}

// And then in my controller method I have...
$this->view->credits = Doctrine_Core::getTable('Model_Credit')->getCreditPurchases($ns->id);
A: 

Man, I'm good at answering my own questions. :)

Found this in the Doctrine docs:

In order for custom Doctrine_Table classes to be loaded you must enable the autoload_table_classes attribute in your bootstrap.php file like done below.

// boostrap.php

// ...
$manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true);
Jeremy Hicks