getSchemaCollection() error

Hi

I am quite new to cake and ran through a tutorial and had everything working however i am developing for real now.

I have a database set-up and the cake intro page says i am connecting to it, however when i do a “cake bake” on a table i get the following errors.

2018-06-13 20:06:44 Error: [Error] Call to a member function getSchemaCollection() on null in C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\ORM\Table.php on line 547

I don’t usually like to ask for help but i have searched and search for info on getSchemaCollection and can’t find anything!

Jon

It literally means your app is trying to call getSchemaCollection() on something that doesn’t exist.
What is the “exact” command you’re trying to use (eg. cake bake model users)?

i was running

cake bake all Purchase

There is a purchase table in the db and indeed cake generate the table->model file but none of the other files

Odd…
And when you just run it again, it doesn’t change?
If not, what is the output you get from the bake tool

I get the following errors


One moment while associations are detected.
Exception: Call to a member function getSchemaCollection() on null in [C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\ORM\Table.php, line 547]
2018-06-15 11:45:46 Error: [Error] Call to a member function getSchemaCollection() on null in C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\ORM\Table.php on line 547
Stack Trace:
#0 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\Task\ModelTask.php(415): Cake\ORM\Table->getSchema()
#1 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\Task\ModelTask.php(231): Bake\Shell\Task\ModelTask->findHasMany(Object(App\Model\Table\PurchaseTable), Array)
#2 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\Task\ModelTask.php(130): Bake\Shell\Task\ModelTask->getAssociations(Object(App\Model\Table\PurchaseTable))
#3 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\Task\ModelTask.php(113): Bake\Shell\Task\ModelTask->getTableContext(Object(App\Model\Table\PurchaseTable), ‘purchase’, ‘Purchase’)
#4 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\Task\ModelTask.php(100): Bake\Shell\Task\ModelTask->bake(‘Purchase’)
#5 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\BakeShell.php(272): Bake\Shell\Task\ModelTask->main(‘Purchase’)
#6 C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\Collection\CollectionTrait.php(51): Bake\Shell\BakeShell->Bake\Shell{closure}(‘Purchase’, 0)
#7 C:\xampp\htdocs\bookmarker\vendor\cakephp\bake\src\Shell\BakeShell.php(273): Cake\Collection\Collection->each(Object(Closure))
#8 C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\Console\Shell.php(518): Bake\Shell\BakeShell->all(‘purchase’)
#9 C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\Console\CommandRunner.php(342): Cake\Console\Shell->runCommand(Array, true)
#10 C:\xampp\htdocs\bookmarker\vendor\cakephp\cakephp\src\Console\CommandRunner.php(164): Cake\Console\CommandRunner->runShell(Object(Bake\Shell\BakeShell), Array)
#11 C:\xampp\htdocs\bookmarker\bin\cake.php(12): Cake\Console\CommandRunner->run(Array)
#12 {main}

it means that for some reason you aren’t properly connecting.
Are you sure the database exists with the tables you’re trying to bake?