Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
65 views

Add.php Form->control not building the proper <select> for the belongsTo association

I'm trying to learn CakePHP and running into some issues (maybe just my misunderstanding) with the ways associations are handled. I have a RESULTS table with a composite key made of two foreign keys ...
EmilienKopp's user avatar
0 votes
1 answer
558 views

CakePHP 4.x hasMany foreach

I'm having some difficulty getting results from a hasMany relationship in my view file. I'm not getting any errors from the debug console so I'm not sure where I'm tripping up. I think that maybe I'm ...
Drew Dello Stritto's user avatar
1 vote
2 answers
780 views

CakePHP3: How to change an association strategy on-the-fly?

I would like to change an association strategy (hasMany) on the fly to "in" (default) to "select". Because this will correct the result for this situation: "Get all publishers and only the first five ...
celsowm's user avatar
  • 354
0 votes
1 answer
574 views

CakePhp3: Select registers count greater than in relationship Has Many

I have one doubt how to solve this. I have two tables, properties and images with a relationship Has Many. One property can have 0,1 or more images related. I want to search properties that has more ...
Rod JI's user avatar
  • 3
0 votes
1 answer
553 views

CakePHP 2.x Order By desc based on HasMany table records

I have Users and Followers table. Followers have HasMany relation with Users i.e. any user can have multiple followers. Array ( [0] => Array ( [User] => Array ...
Saurav Arya's user avatar
-2 votes
2 answers
602 views

Get the related table values in cakephp3

i have 3 tables like A,B and C.. A and B has relation but A and C dont have any connection. B and C related. In cakephp3 index action returns the A and B relation only .. i Need to take the table C ...
user294095's user avatar
1 vote
1 answer
3k views

Creating Association with condition using other association in CakePHP 3

I'm building a cake php 3 app. My app model includes 3 Tables (amongst others): Structures MeasuringPoints DeviceTypes where each Strcuture can have multiple MeasuringPoints: // StrcuturesTable.php ...
Stephan Richter's user avatar
0 votes
2 answers
545 views

How to check if an item belongs to a hasMany association before updating in CakePHP 3.2

What I am trying to do: I have Estimates and Estimates have items "EstimateItems". When updating a Estimate the EstimateItems changed should update. (using patchEntity) This is working with my ...
R. Jordaan's user avatar
1 vote
1 answer
2k views

multiple select for hasMany association in CakePHP 3

I have two tables seller_businesses and seller_business_categories. and their association is as follows SellerBusinessesTable.php $this->hasMany('SellerBusinessCategories', [ '...
Gaurav's user avatar
  • 131
2 votes
0 answers
563 views

CakePHP 3: issue saving hasMany associations

I'm having trouble saving and updating hasMany associations. It seems that Cake can't patch the entity correctly somehow. ProductGroups Table: $this->hasMany('ProductIdentities', [ '...
A.H.'s user avatar
  • 21
0 votes
2 answers
71 views

CakePhp association hasMany

First of all, I know there is a lot of questions like mine, but I tested a lot of solutions, read the documentation but my problem is not solved. I'm using Cakephp 2.x I get 2 tables users and ...
WEGSY85's user avatar
  • 291
0 votes
0 answers
97 views

Query Matching hasMany field in CakePHP

I can't find a working query that match my need. I simply have a Bookings model and a Bookingsstatus : Bookings hasMany Bookingsstatus In that way, I can keep all changes to the status and when I ...
azerto00's user avatar
  • 1,000
0 votes
3 answers
248 views

CakePHP find() conditions for association entries

I have following command, getting me entries from my DB with associated hasMany entries: $teasers = $this->Teaser->find('all', array( 'conditions' => array( 'Teaser.published' =&...
Matt Backslash's user avatar
2 votes
1 answer
2k views

Display all tables fields including hasMany associations in CakePHP 3

I want to fetch all the contents and display them in one table from the tables below: Petrolclaims table $this->belongsTo('Workers', [ 'foreignKey' => 'worker_id', '...
WoonWG's user avatar
  • 27
0 votes
1 answer
386 views

How to fetch rows from associated hasMany model in Cake 3.0?

//PagesTable.php class PagesTable extends Table { public function initialize(array $config) { $this->belongsTo('Books'); } } //BooksTable.php class BooksTable extends Table { ...
Tabrez Ahmed's user avatar
  • 2,950
3 votes
1 answer
827 views

Cakephp hasMany with multiple foreign keys that are not primary keys

I have to use an existing database that can't be modified. There are two tables I need to link with a hasMany relationship (SGRPART hasMany SSGART). The difficulty is that these tables are joined ...
Whatsnew's user avatar
2 votes
1 answer
2k views

CakePHP - Find hasMany association without hasMany relation in Model?

Again I want ask you a question about CakePHP : I have 2 model User and Comment with relation 1-n (One User have many Comment). I want use find() to list infomation both user and it's comments with ...
user3209287's user avatar
1 vote
3 answers
3k views

hasMany relationship with conditions

The subject may be a common question but I have a bit more deeper problem. I am a freshman in CakePhp and already googled the issue. Unfortunately I could not find my exact solution. My database ...
hrnsarac's user avatar
0 votes
1 answer
27 views

Relate Comments with themselves

I'm new to cakePHP and the whole MVC architecture. I want to build a Reddit-like comment system where one Comment hasMany Comment(s) but also one Comment belongsTo (only) one Comment. It is the ...
hytromo's user avatar
  • 1,531
0 votes
1 answer
69 views

Creating relationship between 2 tables in CakePHP using models to write less code

I try to say just CkMmUsersKta.user_id=CkSetupUser.id and define relationship between 2 tables in CakePhp. I defined models and called models in function in controller but says Undefined index for $...
zapata's user avatar
  • 61
0 votes
1 answer
422 views

Cakephp Model with multiple status

I'm asking myself something... Here is the question : I have a model Request. This model has a status. (let's say it is an integer) As the status will change through the time AND as I want to keep a ...
azerto00's user avatar
  • 1,000
0 votes
0 answers
317 views

find doesn't return associated model data cakePHP

models Question and Answer class Question extends AppModel { public $name = "Question"; public $useTable = "questions"; public $primaryKey = 'question_id'; public $hasMany = array( ...
Chanu Rats's user avatar
0 votes
1 answer
143 views

Cakephp: belongsto relation don't working in hasmany relation

I have 3 models: messages, forums and users A forum may have several messages and each message has posted by one user. I would like to have in my forum model all messages and their owner. So, in my ...
MisterDebug's user avatar
0 votes
1 answer
105 views

Complex Searching in CakePHP is not working

I am in a big problem with searching feature, in CakePHP. Actually, I think CakePHP is not the problem here, problem is the logic. I think I don't find the perfect logic for this. I am using CakePHP ...
Musabbir Ahmed's user avatar
1 vote
2 answers
1k views

cakephp-3 hasmany form data save

I have two tables resumes and links. resumes has hasmany relation with links.I want to save many links for single resume. My $this->request->data array is like Array ( [alternate_email] => [...
Archana's user avatar
  • 389
8 votes
2 answers
286 views

hasMany condition show unwanted records cakephp 1.3

I have Questions table which have store so many question. Question related to question_topics so have create has many relationship with question. Now it's look like this: $this->Question->...
Harman's user avatar
  • 1,753
1 vote
0 answers
494 views

Cakephp Containable query with a condition AND model hasMany with also a condition

I'm here to ask a question related to the CakePhp engine. I was just coding when I asked myself this : I have a Customer model that hasMany Address BUT with 2 alias (one for Address.type = "l" and ...
azerto00's user avatar
  • 1,000
0 votes
2 answers
137 views

HasMany Through multiple entries - new

I am playing around with the CourseMembership HasMany through example in the CakePHP cookbook but I cant figure out how to add a new Course and multiple entries into CourseMembership (i.e. student_id ...
Nate88's user avatar
  • 21
0 votes
1 answer
259 views

Cakephp hasMany not JOINing tables

I have three tables jobs,categories and job_categories with similar to below structure: **jobs** id title desc **categories** id name **job_categories** id job_id category_id So I want to ...
Nitish's user avatar
  • 2,743
1 vote
2 answers
65 views

CakePhp associating comments with posts

Following THIS book I'm trying to do that exercise to associate comments with posts, but I'm not getting it. Here is what I tried: class Comments extends AppModel { var $name = 'Comments'; ...
AND4011002849's user avatar
0 votes
2 answers
465 views

hasMany join in cakephp error

I have a table jobs whose structure is similar to below : id desc 1 Job Description And a table job_categories to save the categories of the jobs: id job_id category_id 1 1 ...
Nitish's user avatar
  • 2,743
0 votes
0 answers
420 views

LEFT JOIN like hasMany in cakePHP?

Is there a way to manage LEFT JOIN which gives similar results like hasMany in CakePHP? Let's say that I have two tables: owners: +----+------+ | id | name | +----+------+ | 1 | Paul | | 2 | Adam ...
Tukkan's user avatar
  • 1,617
0 votes
2 answers
161 views

Saving a HasMany relationship data with a compound index in CakePHP

I'm currently using CakePHP 2.x. I make all my forms using the form_helper and then the active record way to save the model data. It's really tidy and simple, but I can't find the way to save one ...
Nazareno Lorenzo's user avatar
0 votes
1 answer
315 views

CakePHP How can I save many records in a link table at once for user - map - attributes?

I have three tables/models: User(id) Map(id, user_id, attribute_id) Attribute (id, name) Map belongsTo the others, the others hasMany Map. I'd like the user (via user controller and user view) to ...
StringsOnFire's user avatar
1 vote
1 answer
394 views

CakePHP: Can't update foreign key for hasMany children in parent

I can't seem to update the foreign key of a child in a hasMany relationship in a parent's edit function. I've checked the data and I'm definitely passing a different parent ID, but regardless of what ...
TurboUser's user avatar
0 votes
1 answer
167 views

CakePHP - How to save single hasMany through record with many belongsTo records per hasMany at once?

My models are essentially owner hasOne album asset hasMany album album belonsTo owner album belongsTo asset A record in 'album' associates an asset to an owner, a 'link', containing extra ...
StringsOnFire's user avatar
1 vote
2 answers
1k views

cakephp: update hasmany related tables

For example, if we have: Array ( [User] => Array ( [id] => 121 [name] => Gwoo the Kungwoo [created] => 2007-05-01 10:31:01 ) [...
Leah's user avatar
  • 245
0 votes
1 answer
135 views

cakephp : hasmany work on localhost but dont work on my VPS contabo

I'm working on website using cakephp , the project work perfectly on localhost but when i upload to my CONTABO VPS i found a problem in the fonction (hasmany) i.e i lose relation ships between models ...
user3169171's user avatar
1 vote
1 answer
156 views

Model related to itself, bi-directional

I have a people table, where people are associated with other people by id. I believe this should be done with a separate table as is standard for such relationships, but I want to be able to retrieve ...
Randy Hall's user avatar
  • 8,077
0 votes
2 answers
623 views

CakePHP hasMany checkbox

I have two tables: Ingredients and Customers. The relationship between them is that Customers hasMany Ingredients. By default when doing the cakebake using the console, the only way to change them is ...
Kelvin's user avatar
  • 903
2 votes
1 answer
4k views

CakePHP remove unwanted relationship

I create some relations Model_One hasMany Model_Two. I create some form with Model_One fields and a three fields likes Model_Two.0.name, Model_Two.1.name, Model_Two.2.name. In beforeSave or ...
kicaj's user avatar
  • 2,948
0 votes
0 answers
76 views

Adding hasMany relation to HABTM join table

I'm stuck with something that is killing me! So, I have Order HABTM Product (with a products_order join table) The join table looks like id | product_id | order_id | quantity | price At the moment,...
azerto00's user avatar
  • 1,000
0 votes
1 answer
443 views

How does this cakephp scaffold know to display the name and not the primary key id?

I am new to cakephp and just created a basic blog using scaffolding. There are two models: User and Post. When the posts are listed, it lists the user's name, which is not the primary key. I am not ...
Philip7899's user avatar
  • 4,667
0 votes
1 answer
508 views

CakePHP remove empty relations

I have relation Holiday hasMany Place (Place belongsTo Holiday). I prepare some form in Holiday view: echo $this->Form->input('name'); echo $this->Form->input('Place.0.name'); echo $this-...
kicaj's user avatar
  • 2,948
0 votes
1 answer
719 views

Retriving data from hasMany table relationship

I have 3 tables: Certificates, Request and Requestc Request hasMany Requestc. Requestc use the certificates_requests table and has id request_id and certificate_id coloumns. I'm trying to retrive ...
Igor Martins's user avatar
  • 2,047
0 votes
1 answer
44 views

Making several tables with hasMany for a complex finding

I'm having trouble assembling the tables where I will search powers of attorney for several companies. where: Prosecutor will belong to several companies (X, Y, Z) Companies have several branches (...
Igor Martins's user avatar
  • 2,047
3 votes
2 answers
5k views

How to 'unlock' a field in a CakePHP form when it is part of a hasMany association

I have a form that represents a RewardModifier table in our database. That RewardModifier hasMany RewardOption. My form is structured like this (image): So, the RewardModifier can have many elements ...
Barry Chapman's user avatar
0 votes
1 answer
151 views

CakePhp find doesn't fetch hasMany relationships

I've got these simple models: // ActivityLog class ActivityLog extends AppModel { public $name = 'ActivityLog'; public $useTable = "activity_logs"; public $hasMeny = array("...
s.susini's user avatar
  • 601
0 votes
1 answer
162 views

execute simple query in cakephp

Movies has many Relations And Relations belongTo Movies . Relations table has movie _id field. i want to show list of relations in view of movies model. so in MoviesController.php i have : public ...
sahar's user avatar
  • 115
4 votes
2 answers
8k views

CakePHP: few joins, belongsTo and hasMany relations done in two queries

I need some help with CakePHP 2.2.3. What I have I have the following setup at the moment: Post hasMany Attachment It works fine and the page is generated with 2 queries: SELECT *, `Post`.`id` ...
ᴍᴇʜᴏᴠ's user avatar