Skip to content
Advertisement

Tag: cakephp

“Cannot convert value to string” when retrieving data (belongsToMany relationship)

I’m using CakePHP 3.3.6 and MySQL 5.7.13. I have these three tables in my database (amongst others) : collections, tags and the join table collections_tags. collections Table tags Table collections_tags Table in my TableCollectionsTable.php: in my TableTagsTable.php: I can get all the Collections or all the Tags. It works. But if I try to get all the Collections with their

how to update a single attribute of an item in a table using CakePHP

I’m trying to update only one piece of information from a user saved in the database, and cakephp accepts an array of values for each attribute, but I don’t have values for other attributes and cakephp will not update the row because it is expecting all the values found in the row. Answer First Way : Create new a Query

CakePHP3: How to run custom SQL query in table model

In CakePHP 3, is it possible to run a custom SQL query from within a table model? If so, how? I tried the following from within a table model: (The query is deliberately simple for example purposes.) But then, when I loop through the $rows, this results in an infinite loop. I’m surprised CakePHP 3 does not clearly document running

Clone entity and all related entities in CakePHP 3

In my CakePHP 3 app, I have a somewhat elaborate tree of entities that I need to clone and save. The root of the structure is a Questionnaire, a Questionnaire hasMany Questions, each Question hasMany Fields, etc. (it goes deeper). Now I want the user to be able to define a new questionnaire by copying an old one. Then they

Virtual fields with Cakephp 3

I need to have a virtual property in my user entity. I followed the CakePHP book. UserEntity.php In a controller I followed exactly the book and I only get a null value. Answer According to @ndm, the problem was due to a bad file naming. I named the user entity class UserEntity.php. The CakePHP name conventions says that: The Entity

installing cakephp 3 manually, without composer

I need to install CakePHP 3 in an old-fashioned upload-unzip-run way. The archive I’ve downloaded from cakephp/cakephp/tags does not contain the default folders like webroot, Model etc., which means it’s not complete. The official documentation does not cover this. Here’s a relevant Github issue I found, but the person ends up still using Composer. There’s also cakephp/app and it seems

Cake php Missing helper, working on local but not on remote

Faced this issue and none of the solutions mentioned online actually helped: Using Cake php all my project was working perfectly fine on a local windows machine but not working on a linux server and I was presented with this error: Eventually I found out that I wasn’t missing any helpers but the issue was in the ctp file and

Cakephp Auth->user() null

In my CakePHP app, I want to include a login form on every page with a login button if the user is not logged in and a logout button if they are logged in. Here is my Auth configuration in AppController.php I want to set a flag that is usable in all the views to check if the user is

AclNode::node() – Couldn’t find Aro node identified by “Array ( [Aro0.model] => User [Aro0.foreign_key] => ) “

User.php class User extends AppModel { } UsersController.php } Group.php } GroupsController.php in StackOverflow already googled and found nothing that could help me. always got the error: AclNode :: node () – Could not find Aro node Identified by “Array ([Aro0.model] => User [Aro0.foreign_key] =>)” believe that somehow the ForeignKey of groups is not being set … but I can

Advertisement