Unable to write any query in controlletr function in cakephp 4.4.17

52 Views Asked by At

I am using cakephp 4.4.17,whenever I am using querybuilder in following way $this->loadModel('Hashtags'); $hashtagsCount = $this->Hashtags->find('all')->count(); No error is occured, screen is blank and white. How to resolve this issue.I have done work in cakephp 2x and 3x but this is completely new to me. Please help

I want to use querybuilder in following way $this->loadModel('Hashtags'); $hashtagsCount = $this->Hashtags->find('all')->count(); or is there any another option to use select query.

1

There are 1 best solutions below

2
On

Your query looks fine. Maybe you have a configuration error. Check you logs and your database connection. Have you upgraded from 4.3.x? If yes then check the app skeleton if anything is missing in bootstrap.php or any other file. https://github.com/cakephp/app other important files to check

  • index.php + .htaccess
  • webroot/index.php + webroot/.htaccess
  • src/Application.php (maybe some Middleware is missing or should be changed - is the ErrorLogger correctly registered)
  • paths.php is every constant there?

Steps to debug: Start with index.php and write something like 'hello'; exit; to different places (one place after another) to verify how far you application gets. I guess the process stops somewhere in your bootstrap.php try to check how far you get and you will find what is missing or different and must be changed.

You could also check the migration guide: https://book.cakephp.org/4/en/appendices/4-4-migration-guide.html