Re: How to save extra field in join table in HATBM Cake1.2
Hi Andre, In the HABTM relationship definition you can define an attribute 'with' where you can specify which model acts as the HABTM model (in your case posts_tags). Then you can create the posts_tags model which gets saved with the additional fields. I have not experimented with it but I saw some articles/posts about this a few days ago (a quick search did not turn up any useful links so you'll have to search for yourself). Hope this helps (or at least a little ;)). Good luck! GrandiJoos On 4 okt, 18:28, Andre <[EMAIL PROTECTED]> wrote: > Hi all, > I saw "Storing additional data on join > table"https://trac.cakephp.org/ticket/828. > Having, two tables associated with HABTM: tags, posts, posts_tags > posts_tags{ post_id,tag_id,weight } > > Can anyone help me showing how to use it, in the Post 's add or Post > 's edit view in to populate "weight" field in posts_tags.weight > column? > > I am thinking to use Checkbox options to select related > posts_tags.weight, And input text to enter weight. > > I've been struggling with this issue for few weeks with HABTM where > the join table record is deleted and reinserted everytime, thus the > posts_tags.weight column were never saved? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Extend running blog example: user makes posts with custom set of tags
Hi all, I ran in a HABTM problem which I'll try to translate to the running blog example used in the CakePHP documentation. Imagine a blog with multiple authors (users) who can post articles and add tags to posts. Now assume that each author has its own set of tags, this would result in the following relationships: User HasMany Posts User HasMany Tags Posts HABTM Tags (and vice versa). Now, when a user creates a post I want to only show his collection of tags, how would I do that? Can I access the userId stored in the session from the model and include it in the HABTM conditional field? Or is there another (neat) trick necessary? Any help is appreciated! GrandiJoos --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Custom views based on action parameters?
Would a simple redirect suffice? Then you could something like $this->redirect('controller/action', null, true); In your case $this->redirect('profile/edit', null, true); Hope this helps. GrandiJoos On 4 okt, 17:41, Lamonte <[EMAIL PROTECTED]> wrote: > How do you switch "views" within a controller action? I have something > setup like the following example.com/users/profile then I might want > to do example.com/users/profile/edit I want to change views inside the > profile action based on the parameter which is set, possible? It yes, > How do you do it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Custom views based on action parameters?
Maybe what he meant was that, depending on some values, you choose which 'partial view' you would like to include next? Like you would have a page build up out of 3 elements and f.i. the middle one changes depending on some values. How to do that exactly I don't know, sorry. GrandiJoos On 4 okt, 17:50, "Lamonte(Scheols/Demonic)" <[EMAIL PROTECTED]> wrote: > No sorry thats not what I'm looking for, basically I want to use more then 1 > view for a single action, I already sorted on how to change views for an > action based on its parameter, but how do I manage to do the same thing but > with more then one view, a guy on IRC said something about "Partial Views", > google didn't turn up with any results. > > > > On Sat, Oct 4, 2008 at 10:47 AM, GrandiJoos <[EMAIL PROTECTED]> wrote: > > > Would a simple redirect suffice? > > > Then you could something like $this->redirect('controller/action', > > null, true); > > In your case $this->redirect('profile/edit', null, true); > > > Hope this helps. > > > GrandiJoos > > > On 4 okt, 17:41, Lamonte <[EMAIL PROTECTED]> wrote: > > > How do you switch "views" within a controller action? I have something > > > setup like the following example.com/users/profile then I might want > > > to do example.com/users/profile/edit I want to change views inside the > > > profile action based on the parameter which is set, possible? It yes, > > > How do you do it. > > -- > Join cleanscript.com Come here for professional PHP coding. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Accessing Multiple database
Hi, As stated by Anja Liebermann, your solution for having city1_xxx tables is as bad as having 4 different databases. The best solution would be your thought I want to make different database for every city and one common database. suppose this website have city1, city2, city3 then there will be 4 different database. common-database city1-database (with tables 1 to 10) city2-database (with tables 1 to 10) city3-database (with tables 1 to 10) Ideal solution 1) 1 database (the 'common' one...) 2) Add the 10 tables from each of the city databases, which have the same structure, to the common database 3) Add 1 field, the cityId for instance, to determine what city the information is about. 4) Make sure you create foreign keys to 'really' reference cities!!! Example: city_infos: (cityid, cityname, inhabitants, ...) {from the common 'database', information per city} cityid is primary key shops (cityid, shopname, size, location, ...) {the 'shops' table from each of the cities databases} cityid is foreign key to city_infos.cityid -- NOTE: You might want to perform step 3 first to each table in each database and then export the contents of each table (and the structure once) and then import them into the common database. In some cases a single field does not suffice but a HABTM [1] relationship is necessary. Furthermore, I would suggest you look into data modelling in general. I suppose [2] and [3] are a good start but any book about database design would suffice. Hope this helps (and if not, let me (/us) know ;) ) GrandiJoos [1] http://book.cakephp.org/view/312/Models [2] http://en.wikipedia.org/wiki/Data_modeling [3] http://en.wikipedia.org/wiki/Relational_model On 2 okt, 14:00, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Well I wouldn't make different Database's unless you really really > must! > Instead stick with 1 DB, but more tables in the DB! > > your thought > I want to make different database for every city and one common > database. suppose this website have city1, city2, city3 then there > will be 4 different database. > common-database > city1-database > city2-database > city3-database > > Well from what I see it is almost finished just miss writen > > so how about just calling all those tables (which would be in a > different DB by you) > city1_xxx > city2_xxx > city3_xxx > > And change the Prefix (implimented in CAKE) in your code to what you > need ;-) Finished > Querying between them is then a piece of Cake since normal Join's can > be used between the Tables > This also saves a LOT of Queries which you be needed to get > information out of every single DB one by one ... > > Greetings Oliver > > On Oct 1, 5:56 pm, "Liebermann, Anja Carolin" > > <[EMAIL PROTECTED]> wrote: > > I guess different tables is as bad a different databases. Why don't you > > have your 10 tables and have the city correlation via an city_id field? > > That is what I would do. > > > Greetings Anja > > > -Ursprüngliche Nachricht- > > Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von > > bookme > > Gesendet: Mittwoch, 1. Oktober 2008 13:25 > > An: CakePHP > > Betreff: Re: Accessing Multiple database > > > Thanks your reply! > > > Each city specific datbase have 10 tables..how can i make them? > > suppose common database has brands table and city1 database has stores > > table, becuase every city has different stores and no realtion to other > > city. so making diffrent database for different city is good I think. > > > Can any one help me? > > > On Oct 1, 3:13 pm, techiguy <[EMAIL PROTECTED]> wrote: > > > > sorry i mean to say one common database and have tables > > > city1,city2,city3 instead of separate databases?? > > > > On Oct 1, 12:31 pm, bookme <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > I am working on a highly dynamic web content site. > > > > This website have two types of data one is common data and second is > > > > city specific. The homepage has listing of all the available cities > > > > which then takes you to that specific cities page. All the code for > > > > a specific city is the same as any other city, the only difference > > > > is the data being pulled from the database only relates to that > > > > specific cities. > > > > > I want to make different database for every city and one common > > > > database. suppose this website have city1, city2, city3 then there > > > > will be 4 different dat
Baking views results in error: missing component session
Hi all, After a few weeks of 'manual baking' I finally found the bake console script. (I know...) After baking a few models and controllers I get an error while baking a view. The error message is: Error: Missing Component file 'session.php' for 'Session' Now I don't know which other session.php (the one in \cake\libs, the one in \cake\libs\controller\components or the one in \cake\libs\views \helpers) to move to what location (\cake\console ???). Any help is appreciated! GrandiJoos --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Create a new model instance and return its new ID
Hi, I want to create a new model instance from a controller (linked to an other model). The data in the model can be populated by the method itself (user id) etc. Furthermore, the id of the just created model should be returned to use as a foreign key in the current model. How do I do this? Sample code: http://bin.cakephp.org/view/997858437 Please help this newbie :p GrandiJoos PS sorry if the information is sparse --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---