Call to a member function fetchAll() on null exception

For programming and general questions on Zend Framework
Post Reply
musa7349
Posts: 3
Joined: Sun Aug 20, 2017 7:17 am

Call to a member function fetchAll() on null exception

Post by musa7349 » Mon Aug 21, 2017 1:28 am

I am new to PHP and Zend Framework. Coming from a Java background. Having started PHP and Zend Framework at the same time using the Tutorial. Just want to share
my experience on my mistakes.

1. The AlbumController.php should be placed on the Application's module.config.php controller key section.
if not, you will keep having the zend Framework index page.
return [
'router' => [
'routes' => [
'home' => [
'type' => Literal::class,
'options' => [
'route' => '/',
'defaults' => [
'controller' => AlbumController::class, //here is the point.
'action' => 'index',
],
],
]

2. If you ever get Call to a member function fetchAll() on null exception.

First check your constructor. PHP uses __ ie two underscores to define constructors. Nest check the $this->table.
The Constructor has to be defined properly and initialized for you to have an object of AlbumTable.

Hope this will help as I could not find anywhere online that talked about this issue. Except for problem 1. Though, later
specified in the tutorial later pages.

Post Reply