Error : Cannot describe <table>. It has 0 columns


#1

Hi,
I have just started learning cakephp and I am a complete beginner. I have setup the cakephp application and app.php I have run this c:\xampp\htdocs\bookmarks>bin\cake bake all users to bake the users from bake console and it was done successfully. Now when i go to the url http://localhost/bookmarks/users/ I am getting the below erors.
Cannot describe users. It has 0 columns.

⟩ Cake\Database\Schema\Collection->describe CORE\src\Database\Schema\CachedCollection.php, line 63
⟩ Cake\Database\Schema\CachedCollection->describe CORE\src\ORM\Table.php, line 531
⟩ Cake\ORM\Table->getSchema CORE\src\ORM\Query.php, line 210
⟩ Cake\ORM\Query->addDefaultTypes CORE\src\ORM\Query.php, line 167
⟩ Cake\ORM\Query->__construct CORE\src\ORM\Table.php, line 1569

Please help me out to remove this database describe error.


#2

Have you checked your user table in your database? Does it have any columns?


#3

Yes, I have checked in the users table. There are four rows in the table.
What does this, it has 0 columns error mean.


#4

The detail error log is as below:

[Cake\Database\Exception] Cannot describe users. It has 0 columns. Request URL: /users Stack Trace: #0 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Database\Schema\CachedCollection.php(63): Cake\Database\Schema\Collection->describe(‘users’, Array) #1 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\ORM\Table.php(531): Cake\Database\Schema\CachedCollection->describe(‘users’) #2 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\ORM\Query.php(210): Cake\ORM\Table->getSchema() #3 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\ORM\Query.php(167): Cake\ORM\Query->addDefaultTypes(Object(App\Model\Table\UsersTable)) #4 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\ORM\Table.php(1569): Cake\ORM\Query->__construct(Object(Cake\Database\Connection), Object(App\Model\Table\UsersTable)) #5 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\ORM\Table.php(1171): Cake\ORM\Table->query() #6 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Controller\Component\PaginatorComponent.php(185): Cake\ORM\Table->find(‘all’, Array) #7 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Controller\Controller.php(717): Cake\Controller\Component\PaginatorComponent->paginate(Object(App\Model\Table\UsersTable), Array) #8 C:\xampp\htdocs\bookmarks\src\Controller\UsersController.php(23): Cake\Controller\Controller->paginate(Object(App\Model\Table\UsersTable)) #9 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Controller\Controller.php(440): App\Controller\UsersController->index() #10 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(119): Cake\Controller\Controller->invokeAction() #11 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\ActionDispatcher.php(93): Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\UsersController)) #12 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\BaseApplication.php(78): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #13 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Http\BaseApplication->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner)) #14 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Routing\Middleware\RoutingMiddleware.php(59): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #15 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Routing\Middleware\RoutingMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner)) #16 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Routing\Middleware\AssetMiddleware.php(88): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #17 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Routing\Middleware\AssetMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner)) #18 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Error\Middleware\ErrorHandlerMiddleware.php(92): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #19 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner)) #20 C:\xampp\htdocs\bookmarks\vendor\cakephp\debug_kit\src\Middleware\DebugKitMiddleware.php(52): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #21 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Runner.php(65): DebugKit\Middleware\DebugKitMiddleware->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response), Object(Cake\Http\Runner)) #22 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Runner.php(51): Cake\Http\Runner->__invoke(Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #23 C:\xampp\htdocs\bookmarks\vendor\cakephp\cakephp\src\Http\Server.php(80): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Cake\Http\ServerRequest), Object(Cake\Http\Response)) #24 C:\xampp\htdocs\bookmarks\webroot\index.php(37): Cake\Http\Server->run() #25 {main}


#5

Did you create the database table yourself? If so Have you defined id as primary key?

Also, navigate to src/Model/Table you wil see a file named UsersTable.php copy paste the validationDefault function code here.


#6

does the table users really exist? Or is it possible that you missed the ‘s’ at the end? =)