PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 3, 2022

[FIXED] find all with cakephp 3 does not return all fields

 February 03, 2022     cakephp, cakephp-3.0, orm     No comments   

Issue

    $users = TableRegistry::getTableLocator()->get('users');
    $user = $users->find()->where(['mail' => 'XXX@XXX.COM'])->first();
    debug($user);

This code returns all the fields of user XXX in DEV environment. However, on PROD, it returns only a few fields (the first ones I created).

I wonder if there is a cache on the queries? If so, how can I reset it ?


Solution

If I clear /www/tmp/cache/*, it works well but I don't know if it's the best way to solve this issue

Specifically the database schema is cached in tmp/cache/models, that is when you're using the default file cache engine.

It's perfectly fine to delete the files, that is what needs to be done in your case, but even better would be to use the schema cache CLI tool, as it will ensure that clearing the cache works for different cache engines too:

bin/cake schema_cache clear

See also

  • Cookbook > Console Tools, Shells & Tasks > Schema Cache Shell


Answered By - ndm
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing