So does than mean I can't run MySQL commands beyonds selects or just for this one example? How do I do run MySQL commands in cakephp, or do I just run raw sqls?
What is the downfall of running raw SQL? Chad On Sat, Dec 27, 2008 at 2:06 PM, Arthur Pemberton <[email protected]> wrote: > > On Sat, Dec 27, 2008 at 12:39 PM, Chad Casselman <[email protected]> > wrote: > > Can someone explain this to me please. I need to under cakephp better in > > order to really leverage it. > > > > If I just run find all, then everything is fine I get data back in the > > format below which is fine; however, if I pass in fields (only need 3 > fields > > from all that information) as in the previous email examples is says that > it > > doesn't know the table.field? Why is this? > > > > How do I get the information below, but create a custom column like > > DateDiff(Package.created, now()). > > Would be easiest to just calculate the date diff in PHP. > > > Array > > ( > > [0] => Array > > ( > > [Package] => Array > > ( > > > > [id] => 2 > > [created] => 2008-12-24 10:48:39 > > [modified] => 2008-12-24 11:39:17 > > [name] => Welcome A - 2 day > > [mailing_id] => 1 > > > > [interval] => 2 > > ) > > > > [Mailing] => Array > > ( > > [id] => 1 > > [created] => 2008-12-24 10:47:40 > > [modified] => 2008-12-24 10:47:40 > > > > [name] => Welcome A > > [description] => Welcome Letter > > [weight] => 1.25 > > [us_shipping] => .42 > > [mex_shipping] => 1.23 > > > > [int_shipping] => 4.50 > > ) > > > > [Sequence] => Array > > ( > > [0] => Array > > ( > > [id] => 2 > > > > [created] => 2008-12-26 14:14:05 > > [modified] => 2008-12-26 14:14:05 > > [name] => Sequence Trial 2 > > [PackagesSequence] => Array > > > > ( > > [id] => 3 > > [package_id] => 2 > > [sequence_id] => 2 > > ) > > > > > > ) > > > > ) > > > > ) > > > > ) > > > > Thanks, > > > > Chad > > > > On Sat, Dec 27, 2008 at 11:18 AM, Webweave <[email protected]> wrote: > >> > >> Your original post showed 'uses' for the tables in question, which > >> infers that you don't have them linked to the controller's model. > >> > >> If they are connected, you may not have recursive set properly to > >> cause Cake to include them. Cake needs to understand how the tables > >> get joined in order to build the SQL. > >> > >> On Dec 27, 6:45 am, "Chad Casselman" <[email protected]> wrote: > >> > Even though the binding is in the models correctly, I have to > respecify > >> > the > >> > associations in this controller that are already in the models that > are > >> > being "used"? Assuming that that HABTM is not going to be a problem. > >> > > >> > Chad > >> > > >> > On Fri, Dec 26, 2008 at 11:11 PM, Webweave <[email protected]> > wrote: > >> > > >> > > In order to fetch data from both tables, you need to join them, Cake > >> > > won't do this automagically. > >> > > >> > > On Dec 26, 5:40 pm, "Chad Casselman" <[email protected]> wrote: > >> > > > Should it bring in all hardcoded (model) associations when I > import > >> > > > them? > >> > > >> > > > Here is what I have and I can't pull any fields from Sequences or > >> > > > PackagesSequence objects/tables > >> > > >> > > > var $uses = array('Package','Sequence','PackagesSequence'); > >> > > > $extra = array( > >> > > > 'recursive' => 1, //int > >> > > > 'fields' => array('Package.name', > 'Sequence.name'), > >> > > //array > >> > > > of field names > >> > > > ); > >> > > >> > > > $this->Package->find('all', $extra); > >> > > >> > > > I get an error that it doesn't know the Sequence table. Thoughts? > >> > > > Do I > >> > > > have to recode the associations already in the models? > >> > > >> > > > Chad > >> > > >> > > > On Fri, Dec 26, 2008 at 6:26 PM, Arthur Pemberton < > [email protected]> > >> > > wrote: > >> > > >> > > > > On Fri, Dec 26, 2008 at 5:14 PM, Chad Casselman > >> > > > > <[email protected]> > >> > > > > wrote: > >> > > > > > I have a Controller for Jobs with a model Job. > >> > > >> > > > > > When I hit /jobs (the index function of Job Controller), I > need > >> > > > > > to > >> > > run a > >> > > > > > query on 2 other tables (not joined to Job) to find values to > >> > > manually > >> > > > > > insert into jobs before actually displaying the index. > >> > > >> > > > > > I have tried several things but can't seem to make any > progress > >> > > > > > on > >> > > this. > >> > > >> > > > > > Can anyone help me with this? > >> > > >> > > > > > 1) select fields from a join on customers and packages > (complex > >> > > > > conditions) > >> > > >> > > > > I believe you want to bind those models to each other [1] > >> > > >> > > > > > 2) iterate through results and insert/update values in job > >> > > >> > > > > Once you setup the appropriate bindings, you can do a > find('all') > >> > > > > on > >> > > > > them and iterate over the results of that. [2] may be clearer. > >> > > >> > > > > > 3) display jobs > >> > > >> > > > > I'm guessing that part already works with your index() action. > >> > > >> > > > > > Thank you in advance. > >> > > >> > > > > > Chad > >> > > >> > > > > [1] > >> > > > > >> > > > > > > http://book.cakephp.org/view/86/Creating-and-Destroying-Associations-. > >> > > .. > >> > > > > [2]http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM > >> > > >> > > > > -- > >> > > > > Fedora 9 : sulphur is good for the skin > >> > > > > (www.pembo13.com) > >> > > >> > > >> > > > > > > > > > > > > > -- > Fedora 9 : sulphur is good for the skin > ( www.pembo13.com ) > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
