Call to a member function fetchAll() on null exception

For programming and general questions on Zend Framework

Call to a member function fetchAll() on null exception

Postby musa7349 on 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.
musa7349
 
Posts: 3
Joined: Sun Aug 20, 2017 7:17 am

Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 4 guests