ACL issue
Please help me resolve this ACL issue. I'm going through the tutorial "10.2.6 An Automated tool for creating ACOs" (http://book.cakephp.org/view/647/An-Automated-tool-for-creating- ACOs) and getting stuck with the following error message when creating the ACOs by running the build_acl(): Fatal error: Call to a member function node() on a non-object in C: \wamp\www\xchange\app\controllers\users_controller.php on line 92 Awaiting any help you can offer Thnx, Sam --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: array extraction
Hi Brian and Adam: Thanx for your help, very much. I've got it working now, using your codes 'combined'. -sam On Jun 17, 12:34 am, brian wrote: > On Tue, Jun 16, 2009 at 9:44 PM, Adam Royle wrote: > > > $this->set() doesn't return a value. so $transaction_amount_total will be > > null. Try something like this: > > > $data = $this->Jurisdiction->Transaction->find('all', array( > > 'conditions' => array('Transaction.jurisdiction_id =' => $id), > > 'fields' => array('Transaction.id','SUM(Transaction.amount) AS Amount')) > > )); > > > $transaction_amount_total = $data[0][0]['Amount']; > > > $this->set('transaction_amount_total, $transaction_amount_total); > > The last 2 lines can be simplified a wee bit: > > $this->set('transaction_amount_total, $data[0][0]['Amount']); > > Or: > > $transaction_amount_total = $data[0][0]['Amount']; > $this->set(compact('transaction_amount_total'), false); > > Note the false param for set. That's required when using compact() and > a var name with underscores. Otherwise, Cake will unleash Inflector on > it, making it camel-cased. > > I have to confess that I'm a bit confused as to what the original > issue was in this thread. If it's just that Cake isn't putting the > calculated field under the modelName key in the $data array, you > should check out this tip: > > http://teknoid.wordpress.com/2008/09/29/dealing-with-calculated-field... --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: array extraction
Hi Adam: I tried it but it wouldn't work. Can anybody else help, please. the original array is an output from a calculated find('all') as in: $transaction_amount_total = $this->set('transaction_amount_total', $this->Jurisdiction->Transaction->find ( 'all',array('conditions'=>array( 'Transaction.jurisdiction_id ='=>$id),'fields' => array ( 'Transaction.id','SUM(Transaction.amount) AS Amount') ) ) ); I don't know if that has anything to do with why I can't any array PHP functions like remove(), array_chunk(), array_slice() etc to work. -sam > On Jun 15, 5:32 pm, "Adam Royle" wrote: > > > use this function, it works well... > > > // recursively reduces deep arrays to single-dimensional arrays > > // $preserve_keys: (0=>never, 1=>strings, 2=>always) > > function array_flatten($array, $preserve_keys = 1, &$return = array()) { > > foreach ($array as $key => $child) { > > if (is_array($child)) { > >$return =& array_flatten($child, $preserve_keys, $return); > > } elseif ($preserve_keys + is_string($key) > 1) { > >$return[$key] = $child; > > } else { > >$return[] = $child; > > } > > } > > return $return; > > > } > > - Original Message - > > From: samuel darko > > To: cake-php@googlegroups.com > > Sent: Tuesday, June 16, 2009 1:16 AM > > Subject: array extraction > > > Hi guys: > > i need help trimming down this: > > > Array( [0] => Array( [0] => Array ( [Amount] => > > 72.64 ) )) > > TO this: > > > Array ( [Amount] => 72.64 )I tried the ff code but to > > no avail:function afterFind($results, $primary=false) { > > if($primary == true) { > >if(Set::check($results, '0.0')) { > > $fieldName = key($results[0][0]);foreach($results as > > $key=>$value) { > > $results[$key][$this->alias][$fieldName] = $value[0][$fieldName]; > > unset($results[$key][0]);} > > } } return $results; > > }Thanks, in advance, for your help > > -sam --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: array extraction
Hi Adam: I tried it but it wouldn't work. Can anybody else help, please. the original array is an output from a calculated find('all') as in: $transaction_amount_total = $this->set('transaction_amount_total', $this->Jurisdiction->Transaction->find('all',array('conditions'=>array ('Transaction.jurisdiction_id ='=>$id),'fields' => array ('Transaction.id','SUM(Transaction.amount) AS Amount'; I don't know if that has anything to do with why I can't any array PHP functions like remove(), array_chunk(), array_slice() etc to work. -sam On Jun 15, 5:32 pm, "Adam Royle" wrote: > use this function, it works well... > > // recursively reduces deep arrays to single-dimensional arrays > // $preserve_keys: (0=>never, 1=>strings, 2=>always) > function array_flatten($array, $preserve_keys = 1, &$return = array()) { > foreach ($array as $key => $child) { > if (is_array($child)) { >$return =& array_flatten($child, $preserve_keys, $return); > } elseif ($preserve_keys + is_string($key) > 1) { >$return[$key] = $child; > } else { >$return[] = $child; > } > } > return $return; > > } > - Original Message - > From: samuel darko > To: cake-php@googlegroups.com > Sent: Tuesday, June 16, 2009 1:16 AM > Subject: array extraction > > Hi guys: > i need help trimming down this: > > Array( [0] => Array( [0] => Array ( [Amount] => 72.64 > ) )) > TO this: > > Array ( [Amount] => 72.64 )I tried the ff code but to > no avail:function afterFind($results, $primary=false) { if($primary > == true) { >if(Set::check($results, '0.0')) { > $fieldName = key($results[0][0]);foreach($results as > $key=>$value) { $results[$key][$this->alias][$fieldName] > = $value[0][$fieldName]; > unset($results[$key][0]);} > } } return $results;} > Thanks, in advance, for your help > -sam --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Please Help on How To Extract Records from Array
hi Sam; Thanx for your help. I finally got it working, was missing simple array outputing syntax. This is what I did, in case anybody may need it later: $val):?> regards -sam On Jun 10, 5:35 pm, "kwameda...@gmail.com" wrote: > Ok, the VIEW display should look like below: > > Agents Employed In This Office (header) > == > 1. John Mensah > 2. Sumani Abdulai > 3. Eric Adotey > 4. Sam Darko > 5. Moses Adjei > 5. Kwabena Kyeremeh > > I fact the above (in an array) is what the print_r outputs and I would > want it in a (possibly) drop-down select option tag even though > 'select option' may not be a native VIEW object. > > -sam > > On Jun 10, 4:04 pm, Sam Sherlock wrote: > > > $Jurisdiction = array( > > "agents" => array( > > "John" => "Mensah", > > "Sumani" => "Abdulai", > > > "Eric" => "Adotey", > > "Sam" => "Darko", > > > "Moses" => "Adjei", > > "Kwabena" => "Kyeremeh" > > ), > > "jurisdiction" => array( > > "Jurisdiction" => array(), > > "Owner" => array(), > > "Agent" => array(), > > "Transaction" => array(), > > "Vendor" => array() > > ), > > "num_agents" => 3 > > ); > > $juris = Set::extract('/agents', $Jurisdiction); > > > foreach($juris[0]['agents'] as $fname => $lname): > > echo("my name is: " . $fname); > > echo("my surname is: " . $lname); > > endforeach; > > > which outputs ==>> > > > my name is: John > > my surname is: Mensah > > > my name is: Sumani > > my surname is: Abdulai > > > my name is: Eric > > my surname is: Adotey > > > my name is: Sam > > my surname is: Darko > > > my name is: Moses > > my surname is: Adjei > > > my name is: Kwabena > > my surname is: Kyeremeh --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Please Help on How To Extract Records from Array
Ok, the VIEW display should look like below: Agents Employed In This Office (header) == 1. John Mensah 2. Sumani Abdulai 3. Eric Adotey 4. Sam Darko 5. Moses Adjei 5. Kwabena Kyeremeh I fact the above (in an array) is what the print_r outputs and I would want it in a (possibly) drop-down select option tag even though 'select option' may not be a native VIEW object. -sam On Jun 10, 4:04 pm, Sam Sherlock wrote: > $Jurisdiction = array( > "agents" => array( > "John" => "Mensah", > "Sumani" => "Abdulai", > > "Eric" => "Adotey", > "Sam" => "Darko", > > "Moses" => "Adjei", > "Kwabena" => "Kyeremeh" > ), > "jurisdiction" => array( > "Jurisdiction" => array(), > "Owner" => array(), > "Agent" => array(), > "Transaction" => array(), > "Vendor" => array() > ), > "num_agents" => 3 > ); > $juris = Set::extract('/agents', $Jurisdiction); > > foreach($juris[0]['agents'] as $fname => $lname): > echo("my name is: " . $fname); > echo("my surname is: " . $lname); > endforeach; > > which outputs ==>> > > my name is: John > my surname is: Mensah > > my name is: Sumani > my surname is: Abdulai > > my name is: Eric > my surname is: Adotey > > my name is: Sam > my surname is: Darko > > my name is: Moses > my surname is: Adjei > > my name is: Kwabena > my surname is: Kyeremeh --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Please Help on How To Extract Records from Array
Thanx Sam, once again, for the help. Ok, I guess I wasn't clear enough, BUT what I really want is to be able to display the records (or arrays?) in this array. Right now I'm only able to show it through the 'print_r': I'm getting an error msg indicating wrong INDEX for array when I try to loop. So, I hope you can now help me with how the code in VIEW should look like. I now have >> foreach($agents as $agent): echo agent['fname']['lname'] enforeach; >> agents" => array( "John" => "Mensah", "Sumani" => "Abdulai", "Eric" => "Adotey", "Sam" => "Darko", "Moses" => "Adjei", "Kwabena" => "Kyeremeh"* ), The final result will be display in the 'view' page of 'Jurisdiction' model -sam On Jun 9, 9:15 pm, Sam Sherlock wrote: > Hi Sam, > I thought you wanted to extract data to make this array > > Array > ( > [0] => Array > ( > [0] => John > [1] => Sumani > [2] => Eric > [3] => Sam > [4] => Moses > [5] => Kwabena > ) > > ) > > as that was highlighted red. > > - S > > 2009/6/9 kwameda...@gmail.com > > > > > Thanks, Sam. > > > But I'm pulling data from the 'Jurisdiction' model, not 'Agent' as in: > > $this->Jurisdiction->Agent->find(..) > > > -sam > > > On Jun 9, 4:57 pm, Sam Sherlock wrote: > > > using this as the path with set::extract > > > > /agents/@* > > > - S > > > > 2009/6/9 samuel darko > > > > > Hi All: > > > > I need help in extracting data from my find('list') result. > > > > > I have $this->Jurisdiction->Agent->find(..) > > > > > and getting the result below but want just a portion of it, highlighted > > in > > > > pink (I've tried using set::combine() to no avail) > > > > > $___viewFn = > > "/home/ilcs/website_files/app/views/jurisdictions/view.ctp" > > > > $___dataForView= array( > > > >*"agents" => array( > > > > >"John" => "Mensah", > > > >"Sumani" => "Abdulai", > > > > >"Eric" => "Adotey", > > > >"Sam" => "Darko", > > > > >"Moses" => "Adjei", > > > >"Kwabena" => "Kyeremeh"* > > > > > ), > > > >"jurisdiction" => array( > > > >"Jurisdiction" => array(), > > > >"Owner" => array(), > > > >"Agent" => array(), > > > >"Transaction" => array(), > > > >"Vendor" => array() > > > > > ), > > > >"num_agents" => 3 > > > > ) > > > > > ... > > > > .. > > > > > Thanks for any help. > > > > Sam Darko --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Please Help on How To Extract Records from Array
Thanks, Sam. But I'm pulling data from the 'Jurisdiction' model, not 'Agent' as in: $this->Jurisdiction->Agent->find(..) -sam On Jun 9, 4:57 pm, Sam Sherlock wrote: > using this as the path with set::extract > > /agents/@* > - S > > 2009/6/9 samuel darko > > > Hi All: > > I need help in extracting data from my find('list') result. > > > I have $this->Jurisdiction->Agent->find(..) > > > and getting the result below but want just a portion of it, highlighted in > > pink (I've tried using set::combine() to no avail) > > > $___viewFn = > > "/home/ilcs/website_files/app/views/jurisdictions/view.ctp" > > $___dataForView= array( > >*"agents" => array( > > >"John" => "Mensah", > >"Sumani" => "Abdulai", > > >"Eric" => "Adotey", > >"Sam" => "Darko", > > >"Moses" => "Adjei", > >"Kwabena" => "Kyeremeh"* > > > ), > >"jurisdiction" => array( > >"Jurisdiction" => array(), > >"Owner" => array(), > >"Agent" => array(), > >"Transaction" => array(), > >"Vendor" => array() > > > ), > >"num_agents" => 3 > > ) > > > ... > > .. > > > Thanks for any help. > > Sam Darko --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Please Help on How To Extract Records from Array
In case you can't see the 'highlighted' portion (it is what I need to extract), here it is: agents" => array( "John" => "Mensah", "Sumani" => "Abdulai", "Eric" => "Adotey", "Sam" => "Darko", "Moses" => "Adjei", "Kwabena" => "Kyeremeh"* ), -sam On Jun 9, 4:43 pm, samuel darko wrote: > Hi All: > I need help in extracting data from my find('list') result. > > I have $this->Jurisdiction->Agent->find(..) > > and getting the result below but want just a portion of it, highlighted in > pink (I've tried using set::combine() to no avail) > > $___viewFn = > "/home/ilcs/website_files/app/views/jurisdictions/view.ctp" > $___dataForView = array( > *"agents" => array( > "John" => "Mensah", > "Sumani" => "Abdulai", > "Eric" => "Adotey", > "Sam" => "Darko", > "Moses" => "Adjei", > "Kwabena" => "Kyeremeh"* > ), > "jurisdiction" => array( > "Jurisdiction" => array(), > "Owner" => array(), > "Agent" => array(), > "Transaction" => array(), > "Vendor" => array() > ), > "num_agents" => 3 > ) > > ... > .. > > Thanks for any help. > Sam Darko --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Why Am I Getting Duplicate Records For My CakePHP View Display
Hi: I need somebody to help fix a problem of duplicate (even triplicate) rows for the same record (with same unique ID) from my table - in my cakephp view displays. I know the problem is definitely coming from Cake because I can confirm that the mysql tables don't have the repeated records. Could it be a pagination bug that I don't know of? here's the code from my 'index' controller and view: FROM index CONTROLLER: - function index() { $this->Jurisdiction->recursive = 0; $this->set('jurisdictions', $this->paginate()); } FROM index VIEW - counter(array( 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) )); ?> link(__('New Jurisdiction', true), array ('action'=>'add')); ?> sort('id');?> sort('name');?> sort('city');?> sort('region');?> sort('description');?> sort('auth_level');?> sort('contact_id');?> Any help would be much appreciated. -sdarko --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---