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
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
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
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
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
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
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
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
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
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
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
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
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
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
2 votes
1 answer
870 views

Using Cakephp, how can I get a multi-select element or checkboxes for a hasMany relationship in my scaffolded add, edit views?

I've run through the Cakephp documentation on linking models together (creating associations), and I can get a single select dropdown in the scaffolded add and edit views by defining a $hasOne member ...
esdot's user avatar
  • 578
1 vote
1 answer
421 views

CakePHP Model Association HasMany - Save Error

I have a model called Game, which has a hasMany relationship with a Planet model (which in turn has a belongsTo defined back to the Game model). Upon creating my first Game record, I use the value of ...
Jimbo's user avatar
  • 109
1 vote
1 answer
327 views

CakePHP - Sorting a model's records by a serialized array of ids stored in another model to which the first array belongs to

I've an hasMany asscociation set up so that an Account has many Sections. The final user can create sections and then sort them. I store the order of the Sections in a serialized array. This is what I ...
checcco's user avatar
  • 35
1 vote
2 answers
4k views

CakePHP increment value

My problem looks as follows: I want to make a vote app where People can choose one or more Events(like Doodle). For this I have set up a function called vote. In the View you can choose the Events ...
ulanBator's user avatar
0 votes
1 answer
547 views

How to UpdateAll with hasMany relationship?

I'm trying to updateall for coloursets. When I read the data into the form, the table is added, but when I try to write back to it, the table isn't joined. Warning (512): SQL Error: 1054: Unknown ...
binky's user avatar
  • 123
1 vote
3 answers
1k views

How should data be formatted in CakePHP to save three levels of associations with saveAll()?

I'm trying to build an "Add an Event" page. You can add multiple "Schedules" - each of which will have calculations run on the date(s) / repeat options you set to create "Dates". -Event hasMany ...
Dave's user avatar
  • 29.1k
1 vote
1 answer
1k views

Save multiple hasMany data with saveAll() in CakePHP without writing id's in the view

I FINALLY got my hasMany data to save using saveAll() - (an Event that hasMany Schedules). I got it to work by repeating through the $this->data['Schedule'] data on the events/admin_edit.ctp, and ...
Dave's user avatar
  • 29.1k
0 votes
3 answers
3k views

CakePHP bizarre saveAll issue. Returns true, but nothing in database

I have two models, Statement -> hasMany -> LineItem. I'm passing the following array to $this->saveAll() inside one of Statement's methods: $data = array( 'Statement' => array( '...
Stephen's user avatar
  • 18.9k