Re: [Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

2016-03-24 Thread 'Steffen Reinig' via CakePHP
=> array ( 'className' => 'User', 'with' => 'PermissionRight', ) ); *Notice* (8): Undefined index: User [*CORE\Cake\Model\Datasource\DboSource.php*, line *1388*] On Monday, March 14, 2016 at 8:29:13 PM UTC+1, John Andersen wrote: > > Check your

Re: [Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

2016-03-14 Thread John Andersen
Check your model names in the HABTM relationships. Looks like you have a mix of singular and plural. Enjoy, John On Monday, 14 March 2016 05:33:36 UTC+2, Steffen Reinig wrote: > > Hello Cakephp Fans, > > today i receive these error: > > Notice (8): Undefined index: Use

[Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

2016-03-13 Thread 'Steffen Reinig' via CakePHP
Hello Cakephp Fans, today i receive these error: Notice (8): Undefined index: User [CORE\Cake\Model\Datasource\DboSource.php, line 1388] Its easy to reproduce: Model: User belongsTo Group Model: Permission habtm Rights (className User) Permission habtm Owners (className User) When i

saveall on habtm creates duplicate new rows

2015-06-10 Thread ajt
Hi, I have a simple HABTM with a lessons/Students table. i simply create a new lesson with an existing student via a while loop , so I should get 2 new rows. I am testing this function. What I get is 4 new rows in the lesson table instead of 2. I have no idea why the extra 2 rows are created

Re: Recursive HABTM Associations?

2015-01-18 Thread Benjamin Krisemendt
at which I currently sit, and so I believe HABTM relationships to be the answer. My attempt to solve this conundrum was to implement a node table and two join tables - children and parents - both of which taking the place of what would be conventionally named nodes_nodes tables. The children join

Can't seem to get simple HABTM to save...

2015-01-11 Thread Jake Newsom
So I have 2 models, Posts and Events. Model Post.php looks like this: ?php App::uses('AppModel','Model'); class Post extends AppModel{ ...took out variables for brevity sake public $hasAndBelongsToMany = array( Events=array( className=Event, joinTable=events_posts, foreignKey=post_id,

Re: Can't seem to get simple HABTM to save...

2015-01-11 Thread John Andersen
Hi Jake Does your events_posts table have a primary key, that is a column named id used for the primary key? If not, then please add such and try again :) Enjoy, John On Sunday, 11 January 2015 16:45:30 UTC+2, Jake Newsom wrote: So I have 2 models, Posts and Events. Model Post.php looks

cant add new record in HABTM table

2014-09-22 Thread ajt
I want to add a new record in a table called TutorsSubject. This table is created from HABTM relationship of Tutor and Subject. Anyway I load the subject names in a text box and I can select a subject name but I cant add a new record. I need to set the id of the tutor_id. There are 3 fields

Re: cant add new record in HABTM table

2014-09-22 Thread Anup Kale
Hvae you tried saveAll($dataArray, array('deep' = true)); ? I use this method to save all my HABTM data. Also, since you are manually setting data maybe, your array is not well formed for CakePHP save(All). Anup On Monday, 22 September 2014 14:21:03 UTC+5:30, ajt wrote: I want to add a new

Re: cant add new record in HABTM table

2014-09-22 Thread ajt
But I dont need a saveall as I save to 1 table only ? Saveall is not appropriate for this. I am not sure what to do here. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the

Re: cant add new record in HABTM table

2014-09-22 Thread Anup Kale
Oh Ok. Now I see what are you doing. If you check the documentation for Cakephp, the association tables gets populated by Cakephp, itself. Howvever if you are saving the data straight into the association tble then do it this way $data['tutor_id'] = 2; $data['subject_id'] =

Dispay data from HABTM in a view

2014-08-30 Thread ajt
Hi , I have the odd situation where I can retrieve data from a HABTM model (from debug array)but cant actually display any of it in the view. I keep getting index undefined error for everything. I want data from both tables but it doesnt work //view doesnt work foreach ($student as $item2

Re: CakePHP 2.5, HABTM save data combining selected data and from multiple inputs

2014-07-14 Thread Dr. Tarique Sani
Mails like these end up in SPAM on Gmail. Use text instead or HTML , you will probably get more replies T On Fri, Jul 11, 2014 at 9:37 PM, Salines nikola.parad...@gmail.com wrote: I have habtm relationship between articles and tags. This works correctly. Now in my Articles/admin_add.ctp

Re: CakePHP 2.5, HABTM save data combining selected data and from multiple inputs

2014-07-14 Thread Salines
Sorry, I copied the question from SO. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails

CakePHP 2.5, HABTM save data combining selected data and from multiple inputs

2014-07-11 Thread Salines
I have habtm relationship between articles and tags. This works correctly. Now in my Articles/admin_add.ctp want beside multiple selection inputs, add fields to add additional tags, and save it all together. echo $this-Form-input('Tag'); // multiple select echo $this-Form-input('Tag.0.name

Re: HABTM table models in alphabetical order required?

2014-07-10 Thread John Andersen
using CakePHP since 2.0, so I'm very familiar with HABTM conventions, including the fact that the tables are named in alphabetical order by convention. In my case, this would be photos_users, but I really hate that because it just seems backward. My question is, will CakePHP break if I name

HABTM table models in alphabetical order required?

2014-07-07 Thread Jamison Bryant
Hi all, I'm developing an application that has Photos and Users. I've been using CakePHP since 2.0, so I'm very familiar with HABTM conventions, including the fact that the tables are named in alphabetical order by convention. In my case, this would be photos_users, but I really hate

Cakephp HABTM association is not working

2014-06-24 Thread Gregory Fox
Hi, I need an association where therapists have many children and visa-versa. I have 3 tables: therapists children children_therapists You can see the association below: Therapist.php public $hasAndBelongsToMany = array('Child' = array(

Re: Cakephp HABTM association is not working

2014-06-24 Thread John Andersen
Check your class name in the association you have defined: 'className' = 'Children', Should it not be: 'className' = 'Child', Enjoy, John On Tuesday, 24 June 2014 14:29:52 UTC+3, Gregory Fox wrote: Hi, I need an association where therapists have many children and visa-versa. I have 3

Re: Deleting an associated HABTM record

2014-05-16 Thread WhyNotSmile
the convention would be for a join table to be flags_invoices (alphabetical), the model name might be FlagsInvoice, even though CakePHP to automagically generate a dynamic model of FlagInvoice while using the HABTM relationship from the Flag or Invoice models. Though it might be easier to explicitly

Multiple HABTM to the same Model

2014-05-16 Thread nook
Hi folks, im goggling for this a few days but can't find a clear solution for my problem. So what i am trying to do is quit simple. I created a *Container* model and this $actsAs tree. Container Database: id, containertype_id, name, parent_id, lft, rght Now i want to create a Contact. A

Deleting an associated HABTM record

2014-05-15 Thread WhyNotSmile
Ok, I'm probably being really dumb here, but I can't figure out how to delete an associated record when the association is HABTM. I have the following: *Invoice:* public $hasAndBelongsToMany = array( 'Flag' = array( 'counterCache' = true, ) ); I can add

Re: Deleting an associated HABTM record

2014-05-15 Thread Reuben
Since the convention would be for a join table to be flags_invoices (alphabetical), the model name might be FlagsInvoice, even though CakePHP to automagically generate a dynamic model of FlagInvoice while using the HABTM relationship from the Flag or Invoice models. Though it might be easier

HABTM relationship between 3 tables

2014-04-10 Thread Jaz
I've done a lot of searching and reading, but I can't seem to figure out the best way to handle this. Any advice would be appreciated: I have a Customer model and a Departure model that have a HABTM relationship. (Customers can sign up for multiple Departures.) I need to keep track

JOIN in belongsTo (but not HABTM)

2013-12-02 Thread Kristen M
Is this possible? Situation: Users have many Items I want to pull a User's total inventory, which sits in the inventory table. But I also need to pull some fields from the master item table (like item name) or to be able to pull items only be their type (this data sits in the master table)

Find and HABTM

2013-10-15 Thread Fabian Olmos
Hi, now I'm trying to retrieve data using find function like this $this-Evento-Behaviors-load('Containable'); $this-Evento-recursive = -1; debug($this-Evento-find('all', array('conditions' = array('Evento.id'=$this-Convert-decode($evento_id)), 'contain' =array(

Re: Find and HABTM

2013-10-15 Thread Reuben
My first guess is because the necessary fields required by the contains statement to do the join are not included when specifying the contains clause for Disciplina and DisciplinasEvento. i.e. the query cant get DisciplinasEvento if Disciplina.id is not retrieved. The query can't get

Stuggling to save HABTM data from a FormHelper form

2013-09-24 Thread Harry Grumbar
I've been wrangling an app with Cake and have got myself stuck with saving HABTM data. To save repeating myself here is the link to my StackOverflow questionhttp://stackoverflow.com/questions/18893392/cakephp-saving-habtm-datawhich I have yet to receive a solution. Basically I have 2 models

Re: Stuggling to save HABTM data from a FormHelper form

2013-09-24 Thread John Andersen
Ps. the above will remove all existing HABTM relationships records for the client, so if you only need to add additional relationship records, then you need to work with the relationship model (join table) instead of with Client and Security. -- Like Us on FaceBook https://www.facebook.com

Re: Stuggling to save HABTM data from a FormHelper form

2013-09-24 Thread John Andersen
Please ensure that your data follows the following structure when saving HABTM data: Array( [0] = Array ( [Client] = Array ( [id] = 12345 ) [Security] = Array ( [id

Model HABTM Model Referencing Original Model

2013-07-29 Thread Benjam Welker
This is a duplicate of my question asked on StackOverflow here: http://stackoverflow.com/questions/17875143/model-habtm-model-referencing-original-model If you could answer the question there, or let me know if it is a bug or not, it would be greatly appreciated. I have a Team model

HABTM and forms

2013-06-25 Thread Gabriele Carioli
Hi everybody, I'm struggling with a particular hasAndBelongsToMany form data problem and need some help. Quickly: 1. A recipe can have many ingredients. 2. An ingredient can be in many recipes. 2. An ingredient in a recipe can be mandatory or optional (or not present). 4. an ingredient in a

Use of intermediate model of HABTM

2013-06-23 Thread wen ger0606
I am using cakephp 2.3.5. There are B and model A model is a relationship HABTM, C model and intermediate model AB is the relationship of hasOne. A.php class A extends AppModel { public $recursive = 2; public $hasAndBelongsToMany = array( 'B' = array( 'with' = 'C

Re: 3 secrets of handling HABTM associations

2013-06-12 Thread icc97
This is an awesome set of tips for a very murky area :) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop

Re: Created and Modified Dates don't auto populate on HABTM

2013-06-11 Thread Iñigo Garcia
if there was a work around. Thanks for the advice, I'll get it set with the join model and go from there. Thanks again. On Feb 17, 3:10 pm, euromark dereurom...@googlemail.com wrote: yep you will need to develop your own HABTM behavior that will take care of that because john is right

Re: HABTM dropdown in add.ctp

2013-05-04 Thread Timon Guggenbuehl
solved -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to

HABTM dropdown in add.ctp

2013-05-03 Thread Timon Guggenbuehl
Hi there, I have 4 tables: - childs - peroples - childs_peoples - type Between childs and parents I have a HABTM relationship, the join table is childs_parents. In my type table there're values like mother, vather, oncle ... On peoples i have a fk to the type table. Now to my actual question

select all HABTM records not in join table

2013-05-02 Thread lowpass
Cake 2.x Item - habtm - Category I'm trying to select all uncategorised Items. There are only 723 records in the items table, 188 of which are uncategorised. I know this last fact because I can run the following query in mysql client: SELECT * FROM items LEFT JOIN categories_items AS ci

Re: select all HABTM records not in join table

2013-05-02 Thread lowpass
' ) ) ); } On Thu, May 2, 2013 at 6:44 PM, lowpass zijn.digi...@gmail.com wrote: Cake 2.x Item - habtm - Category I'm trying to select all uncategorised Items. There are only 723 records in the items table, 188 of which are uncategorised. I know this last fact because I can run the following query in mysql

Re: select all HABTM records not in join table

2013-05-02 Thread Jeremy Burns | Class Outfit
: Cake 2.x Item - habtm - Category I'm trying to select all uncategorised Items. There are only 723 records in the items table, 188 of which are uncategorised. I know this last fact because I can run the following query in mysql client: SELECT * FROM items LEFT JOIN categories_items AS ci

HABTM Reciprocity

2013-04-17 Thread Anthony
Whats the best way to achieve reciprocity between a HABTM self-referencing model? For example: I have a model called Zones it HABTM other Zones. I have the join table setup and everything is working like other HABTM models. But I want the reverse connection to also be established. So

Re: How to perform a find with HABTM relationship?

2013-04-05 Thread Vinicius Dusso
Hi Leonhart, And if you look from another perspective.. Try to perform a search on the Language model, filtering by laguage_name field and then CakePHP will take care of getting the HABTM results from your Post model. What do you think? On Wednesday, April 3, 2013 6:03:09 PM UTC-3, Leonhart

How to perform a find with HABTM relationship?

2013-04-03 Thread Leonhart
How can I perform a find call if I've a Model linked to another one with the Has And Belongs To Many relation? The Models involved are Post and Language. According to the Cake Conventions I've created and populated the Language_Post table. I want to find only the Posts with a specific language

Re: How to perform a find with HABTM relationship?

2013-04-03 Thread Leonhart
Obviously, I meant Languages_Posts table. Sorry for the mistake :) -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group

Re: How to perform a find with HABTM relationship?

2013-04-03 Thread Salines
I do not understand, What do you want to store in languages table? Look here: http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html Dana srijeda, 3. travnja 2013. 15:06:49 UTC+2, korisnik Leonhart napisao je: How can I perform a find call if I've a Model linked to another one

Re: How to perform a find with HABTM relationship?

2013-04-03 Thread Leonhart
contain more than a translation of the article (on the same page) obviously, the right relationship between Link and Language is a HABTM. Well, I need to perform a search on the Link table starting from the language of the content: If a user searches for english contents, I wanna get just the Links

Re: HABTM Inner Join with 3 models

2013-03-20 Thread Jerome Walitzek
Hello, I solved the problem now as follows *JobsController.php* ... $drivers = $this-Job-query(SELECT User.id, (CONCAT(vorname, ' ',nachname)) AS name FROM users AS User INNER JOIN users_events AS Event ON User.id = Event.user_id WHERE Event.event_id = $jobid); ... *edit.ctp* $select_value =

Re: HABTM Inner Join with 3 models

2013-03-19 Thread Jerome Walitzek
Am Dienstag, 19. März 2013 00:42:28 UTC+1 schrieb cricket: On Mon, Mar 18, 2013 at 12:40 PM, Jerome Walitzek jerome@t-online.de javascript: wrote: Hi there, i have a problem with INNER JOIN. Models Job User UsersEvent What are the associations between models? Do

HABTM Inner Join with 3 models

2013-03-18 Thread Jerome Walitzek
Hi there, i have a problem with INNER JOIN. Models Job User UsersEvent In my Job View i would like to get all users which are assigned to an event. I only get successfully the IDs from UsersEvent but not the names from the User Model. In principle I would like to do following: SELECT

Re: HABTM Inner Join with 3 models

2013-03-18 Thread lowpass
On Mon, Mar 18, 2013 at 12:40 PM, Jerome Walitzek jerome.walit...@t-online.de wrote: Hi there, i have a problem with INNER JOIN. Models Job User UsersEvent What are the associations between models? Do you also have an Event model? I ask because that last one looks like a join model

Re: Fixture for the model of a HABTM relationship generates invalid SQL

2013-02-25 Thread marcus33cz
Hi Andrew, I'm having exactly the same problem.. I have a HABTM relationship between (sports) matches and teams. When I try to create a fixture for the MatchesTeam class I get the same error: *Error: *SQLSTATE[42S02]: Base table or view not found: 1146 Table 'c0test.matches_teams' doesn't

Re: Fixture for the model of a HABTM relationship generates invalid SQL

2013-02-25 Thread marcus33cz
Ok so I guess I found the solution for this... Before I was getting this error: Warning: array_map(): An error occurred while invoking the map callback in /var/www/clients/client0/web29/web/lib/Cake/Model/Datasource/DboSource.php on line 451 Warning: Fixture creation for

Re: HABTM Update existing models

2013-02-15 Thread Mateusz Kapusta
all, I've been digging for a good example for exactly what I am trying to do. Most of the samples out there I can find are for HABTM relationships adding and updating, whilst adding a new model instance. What I am after is the update process / procedure required to update

HABTM round trip query

2013-02-10 Thread crouch...@googlemail.com
results in the HABTM model record belonging to the artist. How can a do a round trip in a HABTM relationship? Thanks for all the help, Jay Result: -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you

Re: HABTM round trip query

2013-02-10 Thread lowpass
of languages that the artists speaks only results in the HABTM model record belonging to the artist. How can a do a round trip in a HABTM relationship? Thanks for all the help, Jay Result: -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP

Re: HABTM round trip query

2013-02-10 Thread lowpass
, record 2-ArtistsLanguage, etc...) Comments: Basically, I am looking to find all artists for a given language. This part works, but the result for the list of languages that the artists speaks only results in the HABTM model record belonging to the artist. How can a do a round trip in a HABTM

CakePHP 2.2.5 HABTM Edit view not showing previously selected values as selected.

2013-01-26 Thread Penny Coders
Hey Guys, First of all, a warm hello to everybody here, secondly, i would want to know if somebody can help me with this problem. This is the association part from the Product model, which correlates the Products table with the shipping_methods table, through a join table, called

Re: CakePHP 2.2.5 HABTM Edit view not showing previously selected values as selected.

2013-01-26 Thread lowpass
On Fri, Jan 25, 2013 at 8:03 PM, Penny Coders dtk...@gmail.com wrote: ?php echo $this-Form-input('ShippingMethod',array('label'=false,'multiple'='multiple','class'='chzn-select validate[required]','div'=false,'data-placeholder'='Shipping methods'));? You've specified the model but not the

Re: CakePHP 2.2.5 HABTM Edit view not showing previously selected values as selected.

2013-01-26 Thread Penny Coders
Hey, Thanks, i did try that, no luck tho' Anybody any more ideas? Best Regards, Alex. On Saturday, January 26, 2013 9:49:52 PM UTC+2, cricket wrote: On Fri, Jan 25, 2013 at 8:03 PM, Penny Coders dtk...@gmail.comjavascript: wrote: ?php echo

Re: CakePHP 2.2.5 HABTM Edit view not showing previously selected values as selected.

2013-01-26 Thread Penny Coders
Please note, it DOES show the options, but NOT the previously selected values, compared to another site, on exactly the same procedure does work... On Sunday, January 27, 2013 4:41:46 AM UTC+2, Penny Coders wrote: Hey, Thanks, i did try that, no luck tho' Anybody any more ideas? Best

Re: CakePHP 2.2.5 HABTM Edit view not showing previously selected values as selected.

2013-01-26 Thread John Hardy
print_r your request data and ensure that the schema is matching your intended inputs == print_r($this-request-data); == On Jan 26, 2013, at 6:42 PM, Penny Coders dtk...@gmail.com wrote: Please note, it DOES show the options, but NOT the previously selected values, compared to another

Re: CakePHP 2.2.5 HABTM Edit view not showing previously selected values as selected.

2013-01-26 Thread Penny Coders
//$this-request-data['ShippingMethod'] Array ( [0] = Array ( [id] = 1 [name] = Free Shipping [ProductShippingMethod] = Array ( [id] = 4 [product_id] = 18 [shipping_method_id] = 1 [created] = [modified] = ) ) [1] = Array ( [id] = 3 [name] = FedEx [ProductShippingMethod] = Array ( [id] = 6

Re: queries on HABTM relationships

2013-01-03 Thread lowpass
On Wed, Jan 2, 2013 at 8:32 PM, Stefano Campanella leona...@guildofmessengers.com wrote: Yes I am sure. In my case id is not numeric, the permission name is already an identifier for the permission Your DB schema is broken by design, then. Good luck with that. -- Like Us on FaceBook

Re: queries on HABTM relationships

2013-01-03 Thread Stefano Campanella
Broken for CakePHP or broken in general? Generally, I would not see a problem in using a non-numeric primary key, you just have to be conscious of the constraints this imposes. If it is for a constraint of CakePHP, well I didn't experience any problem with that yet. There is no error in

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Yes I did, but it does not suit my needs or my organization structure. For me it's at the same time too complicated and too limited. I don't need a tree, I need a graph, where a user can have more than one group; because users can be categorized in more than one way. Anyway, do you have any

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
When running a find('count') the contain param is useless. This is because the main query is fetching a sum, not a set of records from which to fetch the associated 'contain' records. Are you using AuthComponent? You can use that to fetch the User and associated records. However, I can't remember

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
mmh, ok. But the problem is that even if I change the find(count) into a find(all) it still loads data only from Group table. Yes I am using the AuthComponent for logged in users. But since I want to use my Authorize class also for managing what anonymous users can access I am calling

Re: queries on HABTM relationships

2013-01-02 Thread Ivan Rimac
This simply is solvable with: $this-Auth-userScope = array('User.can_access_admin' = 1); Put that in you beforeFilter function inside AppController, and your problems are solved. If you want to redirect them, than you shoukd do something like this: if ($this-Auth-user()) {

Re: queries on HABTM relationships

2013-01-02 Thread Leonardo
Excuse me Ivan, but there is no reference to userScope attribute anywhere in the source code of cakePHP, I assume you mean $this-Auth-scope. But it still doesn't help me, is was under the impression that that attribute is used to impose conditions for logging users in, this is not my case, I

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
I think that should be something like: $data = $this-controller()-Group-find( 'count', array( 'conditions' = array( 'Group.id' = 1 // hard-coded for testing? ), 'joins' = array( array(

Re: queries on HABTM relationships

2013-01-02 Thread lowpass
I just realised that this also makes no sense. Why are you running a COUNT(*) on Group when your condition is to select only the Group with id = 1? Perhaps you need to start from the beginning and explain what it is you're looking for. And I'll second the suggestion to use ACL. On Wed, Jan 2,

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Works like a charm! Thank you so much cricket! Now to reply to your questions: I am using a count because I don't need any content returned. With this query I just check if the record exists, if it does then I know the Group has the specified permission. The count will always return 0 if group 1

Re: queries on HABTM relationships

2013-01-02 Thread Maicon Pinto
array('*id*'='can_access_admin') Do you have sure is ID? Usually ID is numeric. Em terça-feira, 1 de janeiro de 2013 19h23min58s UTC-3, Stefano Campanella escreveu: Hello all, this is my first time posting here. I recently started to study how to use CakePHP and I'm trying to develop

Re: queries on HABTM relationships

2013-01-02 Thread Stefano Campanella
Yes I am sure. In my case id is not numeric, the permission name is already an identifier for the permission On Wednesday, January 2, 2013 3:56:41 PM UTC+1, Maicon Pinto wrote: array('*id*'='can_access_admin') Do you have sure is ID? Usually ID is numeric. Em terça-feira, 1 de

Re: Fixture for the model of a HABTM relationship generates invalid SQL

2013-01-01 Thread lowpass
or Group classes: $this-GroupMember-find(...) On Mon, Dec 31, 2012 at 8:32 AM, pyr...@googlemail.com wrote: Hey, I'm having a slight issue with a fixture I'm attempting to create. Basically I have a Member model and a Group model, and they have a HABTM relationship, I've specified a custom

queries on HABTM relationships

2013-01-01 Thread Stefano Campanella
Hello all, this is my first time posting here. I recently started to study how to use CakePHP and I'm trying to develop a website. In my website I am writing a custom authorize component where each user get one or more groups and each group has one or more permissions associated to it. I have

Re: queries on HABTM relationships

2013-01-01 Thread Jeremy Burns | Class Outfit
Have you looked at the inbuilt Auth and ACL components? Might save you a lot of time. Jeremy Burns Class Outfit http://www.classoutfit.com On 1 Jan 2013, at 22:23:58, Stefano Campanella leona...@guildofmessengers.com wrote: Hello all, this is my first time posting here. I recently started

Fixture for the model of a HABTM relationship generates invalid SQL

2012-12-31 Thread pyroka
Hey, I'm having a slight issue with a fixture I'm attempting to create. Basically I have a Member model and a Group model, and they have a HABTM relationship, I've specified a custom model to handle this relationship 'GroupsMember' as I wish to add methods to that model to query the join

Re: Need some HABTM help retrieving related posts

2012-12-17 Thread lowpass
. And change the fetch method, of course. I included the order just to show that it can be. On Sun, Dec 16, 2012 at 3:20 PM, MetZ met...@gmail.com wrote: Okei, so I have a HABTM setup: - posts - tags - posts_tags When creating posts = select multiple tags: example: Tag1, Tag2, Tag3 Each selected

Need some HABTM help retrieving related posts

2012-12-16 Thread MetZ
Okei, so I have a HABTM setup: - posts - tags - posts_tags When creating posts = select multiple tags: example: Tag1, Tag2, Tag3 Each selected tag is saved to posts_tags: id:1, post_id: 44, tag_id: 3 (and so on). Now, displaying my posts, and listing the selected tags, is no problem

Category HABTM Post, find results by selected category and show related posts and paginate by posts?

2012-12-07 Thread Salines
*Category HABTM Post, find results by selected category and show related posts and paginate by posts?* Another day, another problem. When Selecting one category, output will show properly related posts. But the post results need to use pagination. How? Thanks -- Like Us on FaceBook https

Re: Category HABTM Post, find results by selected category and show related posts and paginate by posts?

2012-12-07 Thread jodator
/components/pagination.html On Friday, December 7, 2012 2:58:07 PM UTC+1, Salines wrote: *Category HABTM Post, find results by selected category and show related posts and paginate by posts?* Another day, another problem. When Selecting one category, output will show properly related posts

Re: Category HABTM Post, find results by selected category and show related posts and paginate by posts?

2012-12-07 Thread Salines
I'm lost in the code and reading documents :/ * public function show($slug = null) {* * $this-Category-Behaviors-attach('Containable');* * * * $this-paginate = array(* * 'contain' = array('Post'=array('fields'=array('Post.title'))),* * 'fields' = array('Category.id',

Re: Category HABTM Post, find results by selected category and show related posts and paginate by posts?

2012-12-07 Thread Salines
Solved public function show($slug = null) { $this-Category-recursive = 0; $this-paginate = array( 'joins' = array( array( 'table'= 'categories_posts', 'alias'= 'CategoriesPost', 'type' = 'inner', 'conditions'= array( 'Category.id = CategoriesPost.category_id' ) ), array(

Re: HABTM Join Table Entries Disappearing

2012-12-05 Thread crush
Thanks guys for your help. I think that I have found what is causing the problem but I need some feedback to see if it's probable. Lets say I have the models 'Order' and 'Cart' which have a HABTM relationship with a join model 'CartsOrder'. *When I run this:* $order = $this-Order-find('first

Wishlist: more HABTM sorting/pagination options

2012-11-17 Thread Benjamin Allison
So as far as I can tell, if you want to paginate a model based on the conditions in another model associated via HABTM, you need to do a custom join. It'd be nice to have some convenience methods to make that more Cakey. It's a fairly common need; find posts by author's status, find athletes

Multiple HABTM associations in containable find

2012-11-11 Thread Stuart Bridger
I have HABTM associations between two models but can only get find to return one level. I can return several levels with other associations but think I must be doing something wtong with HABTM. Controller/SchedulesController.php $this-Schedule-find('first', array( 'contain' = array

How to pass HABTM validation errors to FormHelper?

2012-11-01 Thread Nvp
Hi! I read many topics about HABTM validation in Cake but I can't figure out how to solve my problem. I have my main model – Restaurants, it has many HABTM relations to additional models. Now I'm building admin area, and I'm working with new controller in which I have public $uses = array

HABTM and user login

2012-10-29 Thread Álvaro G . Vicario
I have a *User* model to use built-in authentication. The model has several *$hasOne* relationships and all linked models get saved automatically into session, which is great because I can call *AuthComponent**::user()*whenever I need to perform an action based on user data. Now, I've added a

Re: HABTM and user login

2012-10-29 Thread lowpass
That's what I've done in the past when I want to include data that Auth doesn't automatically store. IIRC, you can write to the Auth.User key; the data will then be available from the user() method. $this-Session-write('Auth.User.group', $group_data); Retrieve with $this-Auth-user('group') On

HABTM update

2012-10-15 Thread Juan Ezquerro LLanes
if i have an Agent who have one associated Plugin and i want to add one Plugin more how can i do? if i do: $this-Agent-save( array( 'id' = $data['Agent']['id'], 'Plugin' = array($data['Plugin']['id']) ) ) Old plugin is deleted

HABTM Join Table Entries Disappearing

2012-10-11 Thread crush
Hey, I have an orders table, a carts table and a carts_orders table. Every once and a while, I lose some of the rows from the carts_orders table. They are being created properly but are being deleted at some point. I have been trying to figure it out but everything in the applications works

Re: HABTM Join Table Entries Disappearing

2012-10-11 Thread Jeremy Burns | Class Outfit
By default, Cake clears down the entire habtm table (for the current association) and adds back in just those that are in the current saved dataset. So if a cart has three orders and you try to add another in isolation the first three are cleared and replaced with the new one. If you are trying

Re: HABTM Join Table Entries Disappearing

2012-10-11 Thread Marcus James
If you are using $this-CartsOrder-delete(); then it must be deleting the cartsorder record . You should check for that. Enjoy, Marcus -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are

Re: HABTM Join Table Entries Disappearing

2012-10-11 Thread Keith Gorman | Class Outfit
For 2.x sites you can also set 'unique' = 'keepExisting' to prevent the save from deleting existing records: http://book.cakephp.org/2.0/en/models/saving-your-data.html#what-to-do-when-habtm-becomes-complicated http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#ref

Re: HABTM Join Table Entries Disappearing

2012-10-11 Thread rchavik
not be required). For example: User habtm Role. When updating a User address, you still need to provide the Role data in the POSTed array. To avoid the need of providing the Role data, you could temporarily unbind the relationship using unbindModel() before the call to User-save(). http

Need help with a find on related HABTM relationship

2012-09-28 Thread Clark Ritchie
I'm looking for some guidance here. I have: User hasAndBelongsToMany Project Schema: Users.id Users.name ... Project hasAndBelongsToMany User Schema: Project.id Project.name ... My join table: projects_users.user_id projects_users.project_id Site belongsTo Project Site.id

Re: Need help with a find on related HABTM relationship

2012-09-28 Thread lowpass
You don't really need to add a constraint if your code if you specify the User.id as a condition and run your query on the User model. In Project model: public function fetchAll($user_id = null) { if (!empty($user_id)) { return $this-User-find(

Re: tricky HABTM condition (or maybe situation where multi-column foreign key is needed)

2012-09-27 Thread Carl Clements
On Monday, September 24, 2012 3:30:01 PM UTC-4, cricket wrote: Wasn't there an episode of Laverne Shirley in which Fonzi appeared? Touche. So my example isn't perfect. Although, if I were actually implementing this, I would probably handle that exception by making another Fonzi for LS

Re: tricky HABTM condition (or maybe situation where multi-column foreign key is needed)

2012-09-24 Thread lowpass
Wasn't there an episode of Laverne Shirley in which Fonzi appeared? On Sun, Sep 23, 2012 at 3:46 PM, Carl Clements typo...@clemnet.info wrote: Here is an example almost exactly like the one I am trying to solve, but using more familiar objects (television series) to hopefully allow common

  1   2   3   4   5   6   7   8   9   10   >