所有網頁 圖片 影片 地圖 新聞 網誌搜尋 Gmail 更多 »
最近造訪的群組 | 說明 | 登入
Google 網上論壇首頁
Drop down assocations
目前本群組有太多主題設為優先顯示。要優先顯示這個主題,請將其他主題的這個選項取消。
在處理您的要求時發生錯誤。請再試一次。
標幟
  4 個訊息 - 全部摺疊  -  將全文翻譯為 已翻譯 (查看所有原文)
您要留言的群組是 Usenet 群組。在此群組留言,網際網路上的任何使用者將可以看到您的電郵地址。
您的回覆郵件尚未寄出。
您已成功留言
 
寄件人:
收件人:
副本:
後續追蹤對象:
新增副本 | 新增後續追蹤對象 | 編輯主旨
主旨:
驗證:
為了確認,請輸入您在以下圖片中看到的字元,或輸入您按下存取圖示時所聽到的號碼。 注意聽並輸入您聽到的號碼
 
supergeek79@gmail.com  
檢視個人資料   翻譯為 已翻譯 (查看原文)
 更多選項 11月7日, 上午6時52分
寄件人: "supergee...@gmail.com" <cda...@rvfinancing.com>
日期: Fri, 6 Nov 2009 14:52:37 -0800 (PST)
當地時間: 2009年11月7日(星期六) 上午6時52分
主旨: Drop down assocations
I'm new to cakePhp (and database design...I've been lazy over the
years and want to learn the "right" way to do things) and have a
question about saving the contents of a form that has a drop down
field.

Here are the tables that I have setup in my database:

Table 1: posts (contains id,title,description)

Table 2: categories (contains id,category_name)

Table 3: categories_posts (contains 2 foreign keys:
category_id,post_id)

I have 3 fields in the form I'm building

Field 1 (Category): Drop down field containing a list of categories.
The category id is the value and the category name is shown on the
drop down.

Field 2 (Title): text field

Field 3 (Description): textarea field

I'm having trouble figuring out how to save the Title and Description
fields to one database table, and save the category id and post id to
an assocation table, called categories_posts.

I have tried everything I can find an example of, and nothing has
seemed to work. I'm also not really sure if I need to use the save or
saveAll method.

In the past, I would have just saved the category name to the post
data table and been done with it, but I would like to at least attempt
to normalize my database (which is really foreign to me at this
point...I understand the basic idea but that's about it at this
point).

Can someone please point me in the right direction? If I need to
further explain myself, please let me know. Thank you.


    回覆    回覆作者    轉寄  
您必須先登入才能張貼訊息。
若要張貼訊息,您必須先加入此群組
請在留言之前更新您訂閱設定網頁上的暱稱。
您沒有留言所需的權限。
Robert P  
檢視個人資料   翻譯為 已翻譯 (查看原文)
 更多選項 11月8日, 上午2時31分
寄件人: Robert P <shiftyrobs...@gmail.com>
日期: Sat, 7 Nov 2009 10:31:32 -0800 (PST)
當地時間: 2009年11月8日(星期日) 上午2時31分
主旨: Re: Drop down assocations
Have another review of the concept of normalising, then read
http://book.cakephp.org/view/81/belongsTo

You have normalised your tables to a HABTM relationship, when what you
seem to be after is a hasMany/belongsTo relationship.
    Post belongsTo Category
    Category hasMany Post

When that is done, the dropdown can be automatically generated for you
in your Post views using:
    <?php echo $form->input('Category'); ?>

On Nov 7, 6:52 am, "supergee...@gmail.com" <cda...@rvfinancing.com>
wrote:


    回覆    回覆作者    轉寄  
您必須先登入才能張貼訊息。
若要張貼訊息,您必須先加入此群組
請在留言之前更新您訂閱設定網頁上的暱稱。
您沒有留言所需的權限。
supergeek79@gmail.com  
檢視個人資料   翻譯為 已翻譯 (查看原文)
 更多選項 11月10日, 上午12時39分
寄件人: "supergee...@gmail.com" <cda...@rvfinancing.com>
日期: Mon, 9 Nov 2009 08:39:04 -0800 (PST)
當地時間: 2009年11月10日(星期二) 上午12時39分
主旨: Re: Drop down assocations
Thanks. I'll try that.

On Nov 7, 11:31 am, Robert P <shiftyrobs...@gmail.com> wrote:


    回覆    回覆作者    轉寄  
您必須先登入才能張貼訊息。
若要張貼訊息,您必須先加入此群組
請在留言之前更新您訂閱設定網頁上的暱稱。
您沒有留言所需的權限。
supergeek79@gmail.com  
檢視個人資料   翻譯為 已翻譯 (查看原文)
 更多選項 11月10日, 上午1時54分
寄件人: "supergee...@gmail.com" <cda...@rvfinancing.com>
日期: Mon, 9 Nov 2009 09:54:24 -0800 (PST)
當地時間: 2009年11月10日(星期二) 上午1時54分
主旨: Re: Drop down assocations
Thanks! That worked like a charm.

On Nov 7, 11:31 am, Robert P <shiftyrobs...@gmail.com> wrote:


    回覆    回覆作者    轉寄  
您必須先登入才能張貼訊息。
若要張貼訊息,您必須先加入此群組
請在留言之前更新您訂閱設定網頁上的暱稱。
您沒有留言所需的權限。
無其他留言
« 返回討論主題 « 較新的主題     較舊的主題 »

建立群組 - Google 網上論壇 - Google 首頁 - 服務條款 - 隱私權政策
©2009 Google