controller - Issue retrieving data with options -


I am using the following code to retrieve all messages with the same thread_id for a Customer Portal project. View public threads (thread_id = void) {if (& gt; message- & gt; exists ($ thread_id)) {throwing exception to new nautofoad (__ ('invalid message')); } $ options = array ('conditions' = & gt; array ('Message.thread_id' = & gt; $ thread_id)); $ Message = $ this- & gt; Message-> Search ('all', $ option); $ This- & gt; Set (compact ('message)); }

Currently $ thread_id is set as an integer, although I would eventually like to use a random string.

This works fine if the $ thread_id should also have the record ID in the message table 1 as seen in the table below, however, if the $ thread_id value does not match the record ID, then I Receives an error -

'/ messages / view_thread / 5' did not find the server at

even if a thread of 5 $ message in thread

  id thread_id topic 1 1 test message 2 1 re: test message 6 1) test test message again 1 The T message 24 5 New Test Message can 25 5 Re: New Test Message   

Can someone help me.

I think you should have $ this-> Model- & gt; ; is present (); This will not give you $ thread_id for the id field .... So, try it -

  Public Function View_read ($ thread_id = null) {if (empty ($ thread_id)) {new NotFoundException (__ ('invalid message')); } $ options = array ('conditions' = & gt; array ('Message.thread_id' = & gt; $ thread_id)); $ Message = $ this- & gt; Message-> Search ('all', $ option); If (empty ($ message)) (New Notfound Exception (__ ('Invalid Message'));} $ this-> Set (Compact ('Message'));}   < / Div> 

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -