Re: Advanced setup
Your problem is likely the cause of one of your .htaccess files not set correctly. You probably need a rewrite base. If I get your setup correctly (and I am not at all sure I do) you have the Apache document root set to var/www and everything else if in sub-folders of that. I can't really figure out what you are trying to achieve by this setup.If it is just allowing you and a college to use the same cake core on different development branches of the app on the same server I think you are doing this too complicated for yourself. For example: - Why define APP_DIR with a foldername in an index.php that is in the app dir already? index in webroot will do that correctly for you. Renaming it doesn't hurt this. - The same question for ROOT All you really should need to set is CAKE_CORE_INCLUDE_PATH since it is the only folder you have moved. (you still need working rewrite rules, though.) I never install in this way myself so I have not examples of rewrite settings for you. I hope I could at least point you vaguely in the right direction. /Martin On Sep 22, 1:20 am, The Roman mtes...@gmail.com wrote: Hello, this is my first post so please accept my apologies if I break any conventions. Searches of this site and google at large have not yeilded any results for me, so here goes. I have created a cakePHP site which is to be a sub-system within a larger PHP based intranet. It is hosted on a clients site, to which I have full access. Now, my fellow developer and I use svn source control and so I have been going through the process of making the cake install svn friendly -- splitting of the cake core (cake_1.2.5) to /var/www, having svn ignore the app/tmp directory etc. This is how I have split cake: (from app/index.php) -- if (!defined('ROOT')) { define('ROOT', DS.'var'.DS.'www'.DS.'programmer1'.DS.'main_system'.DS.'cake_systems'); } if (!defined('APP_DIR')) { define('APP_DIR', 'statement_archive'); } if (!defined('CAKE_CORE_INCLUDE_PATH')) { define('CAKE_CORE_INCLUDE_PATH', DS . 'var' . DS . 'www' . DS . 'cake_1.2.5'); } Note that this file is one of those excluded from svn, my coworker will have the same file but his ROOT will use his initials rather than 'programmer1' so that we each have our own development area. So from the above you can see (or hopefully you cannot see, and that is my problem!) that the cake 'app' directory has been renamed to 'statement_archive' and is a sub directory of 'cake_systems'. The idea is that other modules of the php based system may also be done in cake, and that these would also be sub directories of 'cake_systems' and all would share /var/www/cake_1.2.5. Here is where the problem starts. By setting the route for '/' I can get a correctly displayed (layout and all) screen via the urlhttp://xxx.yyy.aaa.bbb/programmer1/main_system/cake_systems/statement This screen provides other links such as --http://xxx.yyy.aaa.bbb/programmer1/main_system/cake_systems/statement Clicking on that link gives a 404 not found -- The requested URL / programmer1/main_system/cake_systems/statement_archive/statements/ generate/280060 was not found on this server. Of course, while under development, when the standard 'development style' cake setup (app directory was called 'app' etc) this all worked. It is almost like cakePHP is getting its hands on the url to do its routing, something is beating it to the punch perhaps? To try and get around this I set some routes manually in statement_archive/ config/routes.php - Router::connect('/statements/generate/*', array('controller' = 'statements', 'action' = 'generate')); Router::connect('/statements/view/*', array('controller' = 'statements', 'action' = 'view')); Router::connect('/statements/edit/*', array('controller' = 'statements', 'action' = 'edit')); Router::connect('/statements/delete/*', array('controller' = 'statements', 'action' = 'delete')); Router::connect('/statements/add/*', array('controller' = 'statements', 'action' = 'add')); Router::connect('/logos', array('controller' = 'logos', 'action' = 'index')); Router::connect('/logos/add/*', array('controller' = 'logos', 'action' = 'add')); Router::connect('/statement_controls', array('controller' = 'statement_controls', 'action' = 'index')); Router::connect('/', array('controller' = 'statements', 'action' = 'index')); Any advice as to how and I can links working again? Many Thanks, The Roman. --~--~-~--~~~---~--~~ 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
Re: CakePHP and scalability
http://www.mysqlperformanceblog.com/ I hope you have seen this blog? They have had a number of post lately about indexes and always post about optimization in one way or the other (funny enough). If you have added indexes which did not improve much you may be defining them wrong for the query you make. You may also need to modify your queries so that they can make use of the indexes. When adding an index it is good to run an explain on the query before and after to see that the index is being used. 300'000rows for a join-table doesn't sound like too much for one server unless you really need to scan most of that table for a lot of queries... like showing a users friends friends friends... I have that and more in both normal tables and joining tables, though your app probably sees more requests than mine (not a public app). I wanted to get to the point that I used to have huge problems with performance. 9/10 of them needed php related optimizations like Containable or doing 3 queries instead of a for loop or a Set::extract (). Once I needed to cache the returned data from Mysql... when generating reporting data and identical queries could be issued 200 times during the same request. On Sep 21, 11:00 pm, byqsri marco.rizze...@gmail.com wrote: My table is about 30 records with only 5 fields It's a jointable of a HABTM relation. But I use this table in some INNER JOIN in some queries that are very slowly. I use memcache. In these cases what is the best practise to consider? On 21 Set, 20:20, Ma'moon phpir...@gmail.com wrote: i was successfully able to handle tables with more than 200 records yes, above 2 million records! with CakePHP and with a very acceptable performance and speed, the first thing that you should be thinking of is sharding the database into smaller chunks DBs, second thing is enabling memcached to reduce DB access specially reducing the master DB hits, thirdly enable APC or whatever bytecode cacher you might be able to use this will gain your web server a very good performance boost, and finally set the debug level for you cake app to 0 to cache the tables DESC operations. Taking all the above into consideration CakePHP can be a very powerful framework to handle huge databases!. On Mon, Sep 21, 2009 at 8:50 PM, Miles J mileswjohn...@gmail.com wrote: Well how big is your table? I have tables with over 200,000+ rows and it works just fine. --http://phpirate.net --~--~-~--~~~---~--~~ 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: Multiple forms in the same view not working
Hi John, thanks for your answer. I take your second advice and it worked. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Auth redirects ssl back to plain http
I was doing a test to see how my app runs under ssl and found that Auth redirects me out of ssl. All other links and redirects appear to work which is why I ask for help. It is surely some detail I have missed since it can't be a bug in Auth or Router. Does anyone know what I might be doing wrong? Examples: https://example.com/ - Location: http://example.com/login https://example.com/login (post form)- http://example.com/ (logged in) --~--~-~--~~~---~--~~ 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: CakePHP and scalability
http://www.mysqlperformanceblog.com/ very interesting. From reading http://www.mysqlperformanceblog.com/2009/09/19/multi-column-indexes-vs-index-merge/ it would appear that for join tables, indexes with both keys would be best, rather than a single key per column. Good tip for the day that :) Cheers, Jon I hope you have seen this blog? They have had a number of post lately about indexes and always post about optimization in one way or the other (funny enough). If you have added indexes which did not improve much you may be defining them wrong for the query you make. You may also need to modify your queries so that they can make use of the indexes. When adding an index it is good to run an explain on the query before and after to see that the index is being used. 300'000rows for a join-table doesn't sound like too much for one server unless you really need to scan most of that table for a lot of queries... like showing a users friends friends friends... I have that and more in both normal tables and joining tables, though your app probably sees more requests than mine (not a public app). I wanted to get to the point that I used to have huge problems with performance. 9/10 of them needed php related optimizations like Containable or doing 3 queries instead of a for loop or a Set::extract (). Once I needed to cache the returned data from Mysql... when generating reporting data and identical queries could be issued 200 times during the same request. On Sep 21, 11:00 pm, byqsri marco.rizze...@gmail.com wrote: My table is about 30 records with only 5 fields It's a jointable of a HABTM relation. But I use this table in some INNER JOIN in some queries that are very slowly. I use memcache. In these cases what is the best practise to consider? On 21 Set, 20:20, Ma'moon phpir...@gmail.com wrote: i was successfully able to handle tables with more than 200 records yes, above 2 million records! with CakePHP and with a very acceptable performance and speed, the first thing that you should be thinking of is sharding the database into smaller chunks DBs, second thing is enabling memcached to reduce DB access specially reducing the master DB hits, thirdly enable APC or whatever bytecode cacher you might be able to use this will gain your web server a very good performance boost, and finally set the debug level for you cake app to 0 to cache the tables DESC operations. Taking all the above into consideration CakePHP can be a very powerful framework to handle huge databases!. On Mon, Sep 21, 2009 at 8:50 PM, Miles J mileswjohn...@gmail.com wrote: Well how big is your table? I have tables with over 200,000+ rows and it works just fine. --http://phpirate.net -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
paginator generates wrong url.
Hi all, the following problem manifests itself in both cake 1.2.4 and 1.2.5. I have a requirement to pass an ID into the index action of a controller that uses the cake paginator. The url would look something like this http://server/path/controller/ index/135. I can generate the url easily for most references to the page (as suggested by the cake manual). However, I have a problem generating the correct url from the paginator. Here is the code I use in the view ($extra is the ID to embed in the url, 135 in this case): $options = array ( 'before' = ' | ', 'after' = ' | ' ); if ( ! empty ( $extra ) ) { $options += array ( 'url' = $extra ); } echo $paginator-first(' '.__('First', true), $options, null, array ('class'='disabled')); echo $paginator-prev(' '.__('previous', true), $options, null, array ('class'='disabled')); echo $paginator-numbers( $options ); echo $paginator-next(__('next', true).' ', $options, null, array ('class'='disabled')); echo $paginator-last(__('last', true).' ', $options, null, array ('class'='disabled')); The 'first', 'numbers' and 'last' methods all generate the correct url: http://server/path/controller/index/135/page:2;. However, the 'next' and 'last' methods generate this error: Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/cake/libs/view/helpers/paginator.php, line 318] and produce this url: http://server/path/controller/%3C%20previous; I tried supplying the ID as an array to 'prev' and 'next' only: $options += array ( 'url' = array ( 'ID' = $extra ) ); but that generates this url: http://server/path/controller/page:2/ID: 135 Is this a bug? Has anyone got a workaround? I have not tried the 'sort' method yet to see if that is affected. Thanks for any help Mal --~--~-~--~~~---~--~~ 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: paginator generates wrong url.
On further investigation, the following bit of code fixes this issue. Please put it in the next release. File cake/libs/view/helpers/paginator.php line 318 change from: $url = array_merge(array('page' = $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url); to: if ( is_array ( $url ) ) { $url = array_merge(array('page' = $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)), $url); } else { $url = array ( $url ) + array('page' = $paging['page'] + ($which == 'Prev' ? $step * -1 : $step)); } On 22 Sep, 12:02, Mal goo...@mmcsoftware.co.uk wrote: Hi all, the following problem manifests itself in both cake 1.2.4 and 1.2.5. I have a requirement to pass an ID into the index action of a controller that uses the cake paginator. The url would look something like this http://server/path/controller/ index/135. I can generate the url easily for most references to the page (as suggested by the cake manual). However, I have a problem generating the correct url from the paginator. Here is the code I use in the view ($extra is the ID to embed in the url, 135 in this case): $options = array ( 'before' = ' | ', 'after' = ' | ' ); if ( ! empty ( $extra ) ) { $options += array ( 'url' = $extra ); } echo $paginator-first(' '.__('First', true), $options, null, array ('class'='disabled')); echo $paginator-prev(' '.__('previous', true), $options, null, array ('class'='disabled')); echo $paginator-numbers( $options ); echo $paginator-next(__('next', true).' ', $options, null, array ('class'='disabled')); echo $paginator-last(__('last', true).' ', $options, null, array ('class'='disabled')); The 'first', 'numbers' and 'last' methods all generate the correct url: http://server/path/controller/index/135/page:2;. However, the 'next' and 'last' methods generate this error: Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/cake/libs/view/helpers/paginator.php, line 318] and produce this url: http://server/path/controller/%3C%20previous; I tried supplying the ID as an array to 'prev' and 'next' only: $options += array ( 'url' = array ( 'ID' = $extra ) ); but that generates this url: http://server/path/controller/page:2/ID: 135 Is this a bug? Has anyone got a workaround? I have not tried the 'sort' method yet to see if that is affected. Thanks for any help Mal --~--~-~--~~~---~--~~ 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: Missing Controller
The directory is app/controllers , not app/controller :) On Tue, Sep 22, 2009 at 1:58 PM, Selva manickaraja mavle...@gmail.comwrote: Hi, I just got CakePhp up and running. To learn the functionality I created sample php code. I followed the instruction in the book that I bought few days back called Beginning CakePHP published by APress. Following are the steps that I had taken. 1. Created a table in PostgreSQL called *items*. 2. Wrote a script called item.php and placed it in app\models directory to define a class called Items. 3. Wrote a script called items_controller and placed it in app\controller direcrtory to define a class called ItemController. Finally I tryped the URL http://localhost/ims/items in the browser. I get an error message Missing Controller. I tried following all the naming convention. I'm attaching the individual files for your reference. Please check and comment as to what had gone wrong. Thank you. Warmest Regards, Selvam --~--~-~--~~~---~--~~ 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: Missing Controller
The class name should be ItemsController controller NOT ItemController On Tue, Sep 22, 2009 at 7:58 AM, Selva manickaraja mavle...@gmail.comwrote: Hi, I just got CakePhp up and running. To learn the functionality I created sample php code. I followed the instruction in the book that I bought few days back called Beginning CakePHP published by APress. Following are the steps that I had taken. 1. Created a table in PostgreSQL called *items*. 2. Wrote a script called item.php and placed it in app\models directory to define a class called Items. 3. Wrote a script called items_controller and placed it in app\controller direcrtory to define a class called ItemController. Finally I tryped the URL http://localhost/ims/items in the browser. I get an error message Missing Controller. I tried following all the naming convention. I'm attaching the individual files for your reference. Please check and comment as to what had gone wrong. Thank you. Warmest Regards, Selvam -- http://phpirate.net --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem with Ajax.autocomplete and Internet Explorer
Hi, I'm using the Ajax Helper for some fields in my app and it works flawlessly from the backend side. The only problem is Internet Explorer where the popup DIV is displayed totally dispositioned, several pixels to the right and lower than it's displayed in Firefox, Opera and any other browser. I'm using the standard code from the CakeBook in my css file to style this DIV. Has anybody had the same problem and solved it somehow? I couldn't find a proper solution apart from setting compatibility mode in IE8, but that's no real solution for my visitors. Thanks in advance for any help --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Configure Cake under Nginx with ssl
If you are running your CakePHP app under Nginx, this might interest you. Cake relies on the php environment variable HTTPS (as in $_SERVER ['HTTPS']) for SSL to be considered by RequestHandler and SecurityComponent. This is a problem for anyone running nginx. HTTPS is not mentioned as a parameter in any php/fastcgi example I have found. Even worse, the ssl module in nginx does not add any variable at all that can be used to set this dynamically. To let php know of the port used you would do fastcgi_param SERVER_PORT $server_port using the provided variable $server_port to set the desires environment variable. No $ssl variable exists and setting true or false based on the port is a bad idea. (I don't know why, that is just what I have read. Performance presumably.) If, like me, you make use of includes a lot there is another stumbling block. Simply adding in the paramater in the server block is not good enough you have to add it on the same structural level as fastcgi_pass and those things. So if you have a vhost file contaning just the barest of info and then you include a cakephp.inc which deals with all the php setups you need do some more work. I went with the cheesy quickfix of copying the cake include and calling it cakephp.ssl.inc... I won't change a lot in those two files so I guess I can remember to make any alterations in both. I hope. (did that make sense without a flowchart?) In short, you need this line among your fcgi params, but only for https requests! just adding it to the list of params will make php think it is always running under ssl. fastcgi_param HTTPS on; /Martin On Sep 22, 10:38 am, Martin Westin martin.westin...@gmail.com wrote: I was doing a test to see how my app runs under ssl and found that Auth redirects me out of ssl. All other links and redirects appear to work which is why I ask for help. It is surely some detail I have missed since it can't be a bug in Auth or Router. Does anyone know what I might be doing wrong? Examples:https://example.com/- Location:http://example.com/loginhttps://example.com/login(post form)-http://example.com/(logged in) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Localization, using multiple pot files
Is it possible to use multiple po files? I have not started with localization yet, so I was wondering if it was possible. What we need is a general translation file, then one that contains all the errors and another one that contains all the help text. So my question is can I switch files somehow? The reason for this is that someone else will write the help texts, and we can then let him do that without having to use 1 big file with ALL our localized text. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Localization, using multiple pot files
Of course you can! __('textString'); // Uses default.po __d('errors', 'textString'); // Uses errors.po __d('help', 'textString'); // Uses help.po On Sep 22, 8:00 am, Crazy crazy...@gmail.com wrote: Is it possible to use multiple po files? I have not started with localization yet, so I was wondering if it was possible. What we need is a general translation file, then one that contains all the errors and another one that contains all the help text. So my question is can I switch files somehow? The reason for this is that someone else will write the help texts, and we can then let him do that without having to use 1 big file with ALL our localized text. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: get all models in app
App::objects('model'); On Sep 21, 5:41 pm, brian bally.z...@gmail.com wrote: I'd like to get--from a shell--the names of all models that are in app/models dir (NOT Cake's models). I realise that I could scan the dir and use Inflector and App:import(), but is there already some way to do this? Nothing in the API jumps out at me. The reason I'd like to do this is to check which models implement a particular Behavior. I know I could keep a list of model names as a class var in the Behavior and import() it into the shell, but then I'd need to update the array each time I add the Behavior to a model's $actsAs array. While that would work, it's not very elegant and prone to error. --~--~-~--~~~---~--~~ 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: how can I pass variable from app_controller to a component?
Why don't you just set the component? $this-Menu-data = $this-data; Or within the component, grab the data from the controller. function setup($Controller) { $this-data = $Controller-data; } --~--~-~--~~~---~--~~ 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: Missing Controller
On 22 sep, 17:57, Selva manickaraja mavle...@gmail.com wrote: Hi Guys, Sorry, made a typo in the email. I did put the file in the correct directory app/controllers and the class name is ItemsController. I'm attaching screenshots of path to both class file and the class defined in each file. I made everything to be the same as found in the book. But it doesn't work. http://book.cakephp.org/view/771/broken most likely you typed the url wrong. hth AD. PS the screenshots are not required. --~--~-~--~~~---~--~~ 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: Multiple forms in the same view not working
Hi John, thanks for your answer. I've taken your second advice and it worked. --~--~-~--~~~---~--~~ 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: Missing Controller
Correct also your model class to Item, not Items! Singular in models, plural in controllers. Enjoy, John [snip] 2. Wrote a script called item.php and placed it in app\models directory to define a class called Items. [/snip] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Using AuthComponent Within a View or Layout
Ok, I tore my hair out over this for a while and then figured out an easy solution. I just wanted to share it for others who run into the same problem. And maybe somebody has an even better solution that I overlooked. Problem: Control accessibility to certain parts of a view or layout using authorization. For example, if there is a 'delete' button, I only want someone who actually has access to delete to even see the button. Wrong Way: My first attempt, after looking all through the documentation without enlightenment, was to try to load the AuthComponent into my layout. This just doesn't work well because the AuthComponent wants a controller, and I didn't want to have to create a controller also and risk other missing parts. Solution: So instead, I just decided to pass my controller to the view using this call from with beforeFilter. I added this into my AppController so all my controllers would behave the same. $this-set('controller', $this); Now in my views and layouts I have $controller and can use the following authentication call: $controller-isAuthorized('controllers/MyController/delete') To make this solution complete for those who need it, here's the isAuthorized method from my AppController. function isAuthorized($action=null) { if(!$action) $action = $this-action; return $this-Acl-check($this-Auth-user(), $action); } I'm curious to hear others' feedback on this approach. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
i18n table with 180 000+ entrys
hei list! I was wondering if the i18n table is still state of the art for about 30 000 entrys (cities) in a model (=180 000 entrys in i18n). Or is there a better solution like using a table prefix for different languages (de_cities, en_cities,)? thankYouVeryMuch chris! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Simple Acl controlled application
Hi I was wondering if any of you could help me, I have been trying to follow the tutorial in the book... http://book.cakephp.org/view/641/Simple-Acl-controlled-Application But I've run into some problems and its pecking my head lol. Is there any chance one of you has a working copy of the source I can download to see where Im going wrong? Any response is greatly appreciated. Chippo --~--~-~--~~~---~--~~ 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: get all models in app
On Tue, Sep 22, 2009 at 12:33 PM, Miles J mileswjohn...@gmail.com wrote: App::objects('model'); Nope. I think that's from an old version. You did jog my memory, though. It's Configure::listObjects('model'). 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Using AuthComponent Within a View or Layout
Use this in your view: if ($session-read('Auth.User.whatever')) { ... Use debug($session-read('Auth')) to see what it looks like. On Tue, Sep 22, 2009 at 12:19 PM, walkerfx st...@walkerfx.com wrote: Ok, I tore my hair out over this for a while and then figured out an easy solution. I just wanted to share it for others who run into the same problem. And maybe somebody has an even better solution that I overlooked. Problem: Control accessibility to certain parts of a view or layout using authorization. For example, if there is a 'delete' button, I only want someone who actually has access to delete to even see the button. Wrong Way: My first attempt, after looking all through the documentation without enlightenment, was to try to load the AuthComponent into my layout. This just doesn't work well because the AuthComponent wants a controller, and I didn't want to have to create a controller also and risk other missing parts. Solution: So instead, I just decided to pass my controller to the view using this call from with beforeFilter. I added this into my AppController so all my controllers would behave the same. $this-set('controller', $this); Now in my views and layouts I have $controller and can use the following authentication call: $controller-isAuthorized('controllers/MyController/delete') To make this solution complete for those who need it, here's the isAuthorized method from my AppController. function isAuthorized($action=null) { if(!$action) $action = $this-action; return $this-Acl-check($this-Auth-user(), $action); } I'm curious to hear others' feedback on this approach. --~--~-~--~~~---~--~~ 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: One to Many
Hmm... Maybe nobody can't understand me, but i show You: My table 'tags' fields: id, name, foreign_key, model, created, modified (table simlar to 'i18n'), and i want adding tags with some content (add event, add post, add article, etc.) - this is simple, but I want automatically fill in the fields: 'foreign_key' and 'model'. My question is: How do I do? Each idea will be helpful! Thanks a lot! Bye On Sep 21, 2:57 pm, kicaj ki...@kdev.pl wrote: Hi, I looking-for solutions like this:http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/attach-com... But I would like automatic set field 'class' and 'foreign_id' (or in beforeSave()) My vision is: One model Comments for many other Models (Post, Event, Article, etc.) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Where to put function needed in multiple models?
I'm trying to follow the structure of CakePHP but I don't know where to put a utility function that I would like to call to filter certain fields in more than one Model. The utility function filters most HTML tags, but allows some safe ones like b etc. and replaces newlines with br. I want to call this utility function in the beforeSave() in more than one Model. So where is the proper place to put it? It's not a behavior (I don't think). Thanks, Ken --~--~-~--~~~---~--~~ 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: Where to put function needed in multiple models?
If calling from beforeSave(), the best place might be AppModel. If you don't already have one of those, copy the file at cake/libs/models/app_model.php to your app directory (not app/models) and modify that. You would then call the function from within your own model as $this-yourFunction(...). Other places to put this function would be bootstrap.php or AppController. If in the former, call it as yourFunction(). If the latter, call it from within a controller as $this-yourFunction(...). On Tue, Sep 22, 2009 at 4:45 PM, kdubya kenwin...@winanstech.com wrote: I'm trying to follow the structure of CakePHP but I don't know where to put a utility function that I would like to call to filter certain fields in more than one Model. The utility function filters most HTML tags, but allows some safe ones like b etc. and replaces newlines with br. I want to call this utility function in the beforeSave() in more than one Model. So where is the proper place to put it? It's not a behavior (I don't think). Thanks, Ken --~--~-~--~~~---~--~~ 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: Where to put function needed in multiple models?
Thank you, Brian. Sounds like an excellent suggestion! (Why didn't I think of that?) On Sep 22, 4:54 pm, brian bally.z...@gmail.com wrote: If calling from beforeSave(), the best place might be AppModel. If you don't already have one of those, copy the file at cake/libs/models/app_model.php to your app directory (not app/models) and modify that. You would then call the function from within your own model as $this-yourFunction(...). snip --~--~-~--~~~---~--~~ 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: One to Many
Use TagBehavior. It does exactly that. http://bakery.cakephp.org/articles/view/simple-tagging-behavior On Tue, Sep 22, 2009 at 4:28 PM, kicaj ki...@kdev.pl wrote: Hmm... Maybe nobody can't understand me, but i show You: My table 'tags' fields: id, name, foreign_key, model, created, modified (table simlar to 'i18n'), and i want adding tags with some content (add event, add post, add article, etc.) - this is simple, but I want automatically fill in the fields: 'foreign_key' and 'model'. My question is: How do I do? Each idea will be helpful! Thanks a lot! Bye On Sep 21, 2:57 pm, kicaj ki...@kdev.pl wrote: Hi, I looking-for solutions like this:http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/attach-com... But I would like automatic set field 'class' and 'foreign_id' (or in beforeSave()) My vision is: One model Comments for many other Models (Post, Event, Article, etc.) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Simple SQL Query that i just cant get right
Hi everybody, this ones been doing my head in for some time now, hope you can help me out, im sure its very simple but i just cant get it working. Firstly the table structure is like this: CREATE TABLE pil ( id int(11) unsigned NOT NULL auto_increment primary key, user_id int(11) unsigned not null, pilid int(11) unsigned NOT NULL, pcode varchar(255), quantity text not null, created DATETIME, modified DATETIME )ENGINE=InnoDB DEFAULT CHARSET=latin1; And this is inside my pils_controller.php: function newpil() { $user_id = $this-Session-read('User.id'); $pilid = $this-Pil-find( array( 'conditions' = array('Pil.user_id' = $user_id), 'fields' = array('Pil.pilid'), 'order' = array('Pil.pilid DESC'), )); $pilid2 = ($pilid['Pil']['pilid'] + 1); ... } What i want is for the above function to pick out the last pil (product inquiry list) that the user set-up and to add a 1 to that. Any ideas where im going wrong? Any help will be greatly appreciated. Thank you Ste --~--~-~--~~~---~--~~ 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: Simple SQL Query that i just cant get right
The first param for find() should be one of 'first', 'all', 'list', etc. But, if all you want is a single value, use field(): function newpil() { $pilid = $this-Pil-field( 'pilid', array( 'Pil.user_id' = $this-Session-read('User.id') ) ) + 1; ... } That being said, I wonder if you're heading into other problems here. Do you know that your table will have duplicates for pilid? Because they will only ever be unique for a particular user_id. In fact, I don't know why you're not just using the primary key for this. It's an auto_increment field and is designed for just this purpose--increment the value for new records while also ensuring that it's unique across all records. On Tue, Sep 22, 2009 at 5:50 PM, Steppio stepisgr...@hotmail.com wrote: Hi everybody, this ones been doing my head in for some time now, hope you can help me out, im sure its very simple but i just cant get it working. Firstly the table structure is like this: CREATE TABLE pil ( id int(11) unsigned NOT NULL auto_increment primary key, user_id int(11) unsigned not null, pilid int(11) unsigned NOT NULL, pcode varchar(255), quantity text not null, created DATETIME, modified DATETIME )ENGINE=InnoDB DEFAULT CHARSET=latin1; And this is inside my pils_controller.php: function newpil() { $user_id = $this-Session-read('User.id'); $pilid = $this-Pil-find( array( 'conditions' = array('Pil.user_id' = $user_id), 'fields' = array('Pil.pilid'), 'order' = array('Pil.pilid DESC'), )); $pilid2 = ($pilid['Pil']['pilid'] + 1); ... } What i want is for the above function to pick out the last pil (product inquiry list) that the user set-up and to add a 1 to that. Any ideas where im going wrong? Any help will be greatly appreciated. Thank you Ste --~--~-~--~~~---~--~~ 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: get all models in app
Well no its actually not, Configure::listObjects('model') calls App::objects('model') internally though. But I forget which one will be deprecated :P On Sep 22, 12:45 pm, brian bally.z...@gmail.com wrote: On Tue, Sep 22, 2009 at 12:33 PM, Miles J mileswjohn...@gmail.com wrote: App::objects('model'); Nope. I think that's from an old version. You did jog my memory, though. It's Configure::listObjects('model'). 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Where to put function needed in multiple models?
Hi kdubya, I'm trying to follow the structure of CakePHP but I don't know where to put a utility function that I would like to call to filter certain fields in more than one Model. The utility function filters most HTML tags, but allows some safe ones like b etc. and replaces newlines with br. I want to call this utility function in the beforeSave() in more than one Model. So where is the proper place to put it? It's not a behavior (I don't think). Sounds like a perfect candidate for a behaviour to me. It's not applicable to all models, you wouldn't want your User or Group model to be checked, and perhaps you have different field names in different models that need checking, these would go in the config array. here;s an idea: var $actsAs = array( 'Cleanup'=array('body') ); class CleanupBehavior extends ModelBehavior { /** * Contain settings indexed by model name. * * @var array * @access private */ var $__settings = array(); /** * setups the behaviour * * @param object $model the model that the behaviour is called from * @param array $settings the settings array defined in the model */ function setup($Model, $settings = array()) { if (!isset($this-__settings[$Model-alias])) { if (!empty($settings)) { foreach($settings as $field=$options) { $this-__settings[$Model-alias][$field] = am($this-__default, $options); } } } } /** * beforeSave callback * */ function beforeSave($Model) { foreach($this-__settings[$Model-alias] as $field = $options) { if(isset($Model-data[$Model-alias][$field])) { // clean data - obviously does nothing at the mo! $Model-data[$Model-name][$field] = $Model-data[$Model-name][$field]; } } return parent::beforeSave($Model); } } hth jon -- jon bennett w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ 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: Simple SQL Query that i just cant get right
Thanks for the response. Basically its a bit like a shopping cart. I need a primary key just to keep each entry into the Product Inquiry List seperate, for example some of the lines i have in the database at the moment are: ID | User ID |Pilid|pcode| quantity | ... 13 58 1 CM221 14 58 1 CD013 15 58 1 CM003 6 16 58 1 CM1/3 1 17 58 1 CM451 3 When i want to add a new pil i click on the function newpil(), which at the moment does this 18 58 2 -- -- This is what i want, but when i use the function newpil() again i want the latest pilid for that user to increment again, i.e. 19 58 3 -- -- What you have sent me worked if the Pilid was 1, it added a 1 to the 'pilid' in the find query, but once it gets to 2 it seems to stop, just keeps being pilid = 2. I know this is a wierd way to do it but it seemed to work in my head :/ Again thanks for the response. On 22 Sep, 23:06, brian bally.z...@gmail.com wrote: The first param for find() should be one of 'first', 'all', 'list', etc. But, if all you want is a single value, use field(): function newpil() { $pilid = $this-Pil-field( 'pilid', array( 'Pil.user_id' = $this-Session-read('User.id') ) ) + 1; ... } That being said, I wonder if you're heading into other problems here. Do you know that your table will have duplicates for pilid? Because they will only ever be unique for a particular user_id. In fact, I don't know why you're not just using the primary key for this. It's an auto_increment field and is designed for just this purpose--increment the value for new records while also ensuring that it's unique across all records. On Tue, Sep 22, 2009 at 5:50 PM, Steppio stepisgr...@hotmail.com wrote: Hi everybody, this ones been doing my head in for some time now, hope you can help me out, im sure its very simple but i just cant get it working. Firstly the table structure is like this: CREATE TABLE pil ( id int(11) unsigned NOT NULL auto_increment primary key, user_id int(11) unsigned not null, pilid int(11) unsigned NOT NULL, pcode varchar(255), quantity text not null, created DATETIME, modified DATETIME )ENGINE=InnoDB DEFAULT CHARSET=latin1; And this is inside my pils_controller.php: function newpil() { $user_id = $this-Session-read('User.id'); $pilid = $this-Pil-find( array( 'conditions' = array('Pil.user_id' = $user_id), 'fields' = array('Pil.pilid'), 'order' = array('Pil.pilid DESC'), )); $pilid2 = ($pilid['Pil']['pilid'] + 1); ... } What i want is for the above function to pick out the last pil (product inquiry list) that the user set-up and to add a 1 to that. Any ideas where im going wrong? Any help will be greatly appreciated. Thank you Ste --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Optimizing pagination COUNT(*) query
I've been working on trying to optimize my code for a client before we decide to throw more hardware at the problem. One thing that I have noticed is the way that COUNT(*) queries are generated for pagination where the controller FIND method includes a JOIN table. For example here's one of the queries generated via the CakePHP pagination: SELECT COUNT(*) AS `count` FROM `trades` AS `Trade` left JOIN ratings AS `Rating` ON (`Trade`.`cusip` = `Rating`.`cusip`) WHERE `Trade`.`trade_date` = '2009-09-11' AND `Trade`.`state_id` = 5; In this case, it seems like LEFT joins should not be included in the COUNT query because it has no effect on the records returned. After some testing, there is a performance hit: mysql SELECT COUNT(*) AS `count` FROM `trades` AS `Trade` left JOIN ratings AS `Rating` ON (`Trade`.`cusip` = `Rating`.`cusip`) WHERE `Trade`.`trade_date` = '2009-09-11' AND `Trade`.`state_id` = 5; +---+ | count | +---+ | 4771 | +---+ 1 row in set (0.10 sec) And now WITHOUT the JOIN: mysql SELECT COUNT(*) AS `count` FROM `trades` AS `Trade` WHERE `Trade`.`trade_date` = '2009-09-11' AND `Trade`.`state_id` = 5; +---+ | count | +---+ | 4771 | +---+ 1 row in set (0.00 sec) Ideally LEFT joins should not be included in the COUNT(*) query for pagination. I could be wrong here but just looking to get some opinions. --~--~-~--~~~---~--~~ 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: Optimizing pagination COUNT(*) query
You can unbind the referenced table before you run your query and it will not be included... http://book.cakephp.org/view/78/Associations-Linking-Models-Together http://book.cakephp.org/view/78/Associations-Linking-Models-Together // This fetches Leaders, and their associated Followers $this-Leader-find('all'); // Let's remove the hasMany... $this-Leader-*unbindModel*( array('hasMany' = array('Follower')) ); // Now using a find function will return // Leaders, with no Followers $this-Leader-find('all'); On Tue, Sep 22, 2009 at 5:45 PM, DanielMedia danielmedi...@gmail.comwrote: I've been working on trying to optimize my code for a client before we decide to throw more hardware at the problem. One thing that I have noticed is the way that COUNT(*) queries are generated for pagination where the controller FIND method includes a JOIN table. For example here's one of the queries generated via the CakePHP pagination: SELECT COUNT(*) AS `count` FROM `trades` AS `Trade` left JOIN ratings AS `Rating` ON (`Trade`.`cusip` = `Rating`.`cusip`) WHERE `Trade`.`trade_date` = '2009-09-11' AND `Trade`.`state_id` = 5; In this case, it seems like LEFT joins should not be included in the COUNT query because it has no effect on the records returned. After some testing, there is a performance hit: mysql SELECT COUNT(*) AS `count` FROM `trades` AS `Trade` left JOIN ratings AS `Rating` ON (`Trade`.`cusip` = `Rating`.`cusip`) WHERE `Trade`.`trade_date` = '2009-09-11' AND `Trade`.`state_id` = 5; +---+ | count | +---+ | 4771 | +---+ 1 row in set (0.10 sec) And now WITHOUT the JOIN: mysql SELECT COUNT(*) AS `count` FROM `trades` AS `Trade` WHERE `Trade`.`trade_date` = '2009-09-11' AND `Trade`.`state_id` = 5; +---+ | count | +---+ | 4771 | +---+ 1 row in set (0.00 sec) Ideally LEFT joins should not be included in the COUNT(*) query for pagination. I could be wrong here but just looking to get some opinions. --~--~-~--~~~---~--~~ 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: Optimizing pagination COUNT(*) query
Thanks for the reply Dave. I should have been more clear. I still need the JOIN to happen on the data returned but the JOIN should not happen on the paginator's COUNT(*) query. Seems to be adding overhead that is not necessary since the left join will not affect the count returned by that query. --~--~-~--~~~---~--~~ 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: Optimizing pagination COUNT(*) query
Not sure how you would edit the query for that, but you can create your own paginationCount() method and rewrite the conditions and call the parent. http://book.cakephp.org/view/249/Custom-Query-Pagination --~--~-~--~~~---~--~~ 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: Optimizing pagination COUNT(*) query
Thanks Miles. I was avoiding having to do that but I guess that's the only approach right now. I'm actually in the middle of testing if this is a Cake issue or something weird in my custom App Model. I will report back if the same issue occurs in a default Cake install. If that's the case, maybe the Cake devs can consider making that change in the core for performance reasons. --~--~-~--~~~---~--~~ 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: Simple SQL Query that i just cant get right
On 09/22/2009 07:30 PM, Steppio wrote: Thanks for the response. Basically its a bit like a shopping cart. I need a primary key just to keep each entry into the Product Inquiry List seperate, for example some of the lines i have in the database at the moment are: ID | User ID |Pilid|pcode| quantity | ... 13 58 1 CM221 14 58 1 CD013 15 58 1 CM003 6 16 58 1 CM1/3 1 17 58 1 CM451 3 When i want to add a new pil i click on the function newpil(), which at the moment does this 18 58 2 -- -- This is what i want, but when i use the function newpil() again i want the latest pilid for that user to increment again, i.e. 19 58 3 -- -- What you have sent me worked if the Pilid was 1, it added a 1 to the 'pilid' in the find query, but once it gets to 2 it seems to stop, just keeps being pilid = 2. I know this is a wierd way to do it but it seemed to work in my head :/ Again thanks for the response. On 22 Sep, 23:06, brianbally.z...@gmail.com wrote: The first param for find() should be one of 'first', 'all', 'list', etc. But, if all you want is a single value, use field(): function newpil() { $pilid = $this-Pil-field( 'pilid', array( 'Pil.user_id' = $this-Session-read('User.id') ) ) + 1; ... } That being said, I wonder if you're heading into other problems here. Do you know that your table will have duplicates for pilid? Because they will only ever be unique for a particular user_id. In fact, I don't know why you're not just using the primary key for this. It's an auto_increment field and is designed for just this purpose--increment the value for new records while also ensuring that it's unique across all records. On Tue, Sep 22, 2009 at 5:50 PM, Steppiostepisgr...@hotmail.com wrote: Hi everybody, this ones been doing my head in for some time now, hope you can help me out, im sure its very simple but i just cant get it working. Firstly the table structure is like this: CREATE TABLE pil ( id int(11) unsigned NOT NULL auto_increment primary key, user_id int(11) unsigned not null, pilid int(11) unsigned NOT NULL, pcode varchar(255), quantity text not null, created DATETIME, modified DATETIME )ENGINE=InnoDB DEFAULT CHARSET=latin1; And this is inside my pils_controller.php: function newpil() { $user_id = $this-Session-read('User.id'); $pilid = $this-Pil-find( array( 'conditions' = array('Pil.user_id' = $user_id), 'fields' = array('Pil.pilid'), 'order' = array('Pil.pilid DESC'), )); $pilid2 = ($pilid['Pil']['pilid'] + 1); ... } What i want is for the above function to pick out the last pil (product inquiry list) that the user set-up and to add a 1 to that. Any ideas where im going wrong? Any help will be greatly appreciated. Thank you Ste As Brian said, just add 'first' to your code and that should do the job: $this-Pil-find('first', array( --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Element question
I am trying to use an element inside a foreach loop. I have the same code in 3 places and figured it would be easier to put the duplicated code into an element and just render the 1 where needed. I put the element inside the foreach because the $award is is different how it is obtained, its not always foreach ($user['Award'] as $award) that's why I left it outside the element. example: foreach ($user['Award'] as $award):? ?php echo $this-element('users/block_awards'); ? ?php endforeach; ? OR foreach ($campaign['User']['Award'] as $award):? ?php echo $this-element('users/block_awards'); ? ?php endforeach; ? But the $award inside the element comes back Undefined variable: award Am I missing something here? Cant be done this way? Dave --~--~-~--~~~---~--~~ 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: Element question
That's because the element relies on $viewVars. $award is outside the element's scope because you created it in your view. At least, I believe that's the case. Do this instead: echo $this-element('users/block_awards', array('award' = $award)); That should pass your var to the element. On Tue, Sep 22, 2009 at 8:51 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am trying to use an element inside a foreach loop. I have the same code in 3 places and figured it would be easier to put the duplicated code into an element and just render the 1 where needed. I put the element inside the foreach because the $award is is different how it is obtained, its not always foreach ($user['Award'] as $award) that's why I left it outside the element. example: foreach ($user['Award'] as $award):? ?php echo $this-element('users/block_awards'); ? ?php endforeach; ? OR foreach ($campaign['User']['Award'] as $award):? ?php echo $this-element('users/block_awards'); ? ?php endforeach; ? But the $award inside the element comes back Undefined variable: award Am I missing something here? Cant be done this way? Dave --~--~-~--~~~---~--~~ 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: Element question
Right on thanks. Found it too after doing a little digging in the cookbook. Thanks again, Dave -Original Message- From: brian [mailto:bally.z...@gmail.com] Sent: September-22-09 10:44 PM To: cake-php@googlegroups.com Subject: Re: Element question That's because the element relies on $viewVars. $award is outside the element's scope because you created it in your view. At least, I believe that's the case. Do this instead: echo $this-element('users/block_awards', array('award' = $award)); That should pass your var to the element. On Tue, Sep 22, 2009 at 8:51 PM, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: I am trying to use an element inside a foreach loop. I have the same code in 3 places and figured it would be easier to put the duplicated code into an element and just render the 1 where needed. I put the element inside the foreach because the $award is is different how it is obtained, its not always foreach ($user['Award'] as $award) that's why I left it outside the element. example: foreach ($user['Award'] as $award):? ?php echo $this-element('users/block_awards'); ? ?php endforeach; ? OR foreach ($campaign['User']['Award'] as $award):? ?php echo $this-element('users/block_awards'); ? ?php endforeach; ? But the $award inside the element comes back Undefined variable: award Am I missing something here? Cant be done this way? Dave --~--~-~--~~~---~--~~ 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: Missing Controller
Yes, I had corrected that all the first time I sent the email. According to the book tutorial, I should be getting the view. But I am still stuck with the error message Missing Controller. Could it be environment setup? Please advice Thank you. On Wed, Sep 23, 2009 at 1:17 AM, John Andersen j.andersen...@gmail.comwrote: Correct also your model class to Item, not Items! Singular in models, plural in controllers. Enjoy, John [snip] 2. Wrote a script called item.php and placed it in app\models directory to define a class called Items. [/snip]e --~--~-~--~~~---~--~~ 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: Advanced setup
Thanks for the response. As you say, the setup was overly complicated, and going back to square one certainly helped. I had followed advice (as I read it, anyway) from the an article on the bakery and moved webroot/index down a level into app, which just confused the situation even if it was not a problem. Also I had rename the cake_1.2.5 directory which does seem to upset the apple- cart. I wanted to do that so that I had nicer looking urls, but I can live with what I have. I have no problems renaming the app dir itself, which is enough for me. As you say, I simply wound up specifing CAKE_CORE_INCLUDE_PATH to point to cake and vendors directories which had been removed to somewhere outside the subversion tree. Many Thanks, Roman. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Model update problems
Hi everyone! I had a running simple application in wich you were able to see images in an image gallery. The problem started when I tried to add a Thumb image. I changed the model in my database by adding a new column 'thumb_url' so I could save the thumb address of an image. The thing is that I can't get to save nor read anything in/from that new column (I'm doing exactly the same than before but with one extra line: $this- data['new']['thumb_url'] = $thumb_url;). Is there any other thing that I should do to force cake to recognize that new column?? I would really appreciate some help here!! Thanks a lot! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Paginate - order clause is ambiguous!
Hello everyone! I'm having a problem here. I have a table Pages, which belongsTo Categories. I'm using an ordenable behaviour, and so both pages and categories have a field called index. Problem is, in my pages_controller, i wrote this: var $paginate = array ('order' = 'index'); And as a result, I receive an error saying SQL Error: 1052: Column 'index' in order clause is ambiguous It must be because both categories and pages have the same field. I cant change this field...so how can I specify that I want to use the index from the Pages table? Thanks!! -- View this message in context: http://www.nabble.com/Paginate---order-clause-is-ambiguous%21-tp25530985p25530985.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: how can I pass variable from app_controller to a component?
Well, problem solved...don't know if I did it the right way, though... Since the variable I was trying to use in my component was an array of data from a table, I had to import the model in the component using: $Category = ClassRegistry::init('Category'); So I set the array after that, in the component as well, like this: $categories = $Category-find('all',array( 'conditions'=array('Category.active'=1), 'order'= array('Category.index'='ASC') )); Thanks! mig_akira wrote: Hello everyone. I'm trying to build a simple dropdown menu for a website. I'm using this tutorial: http://www.palivoda.eu/2008/04/dynamic-menu-in-cakephp/ THe menu is working, but I don't know how can I pass the array with all the data to build the menu from the app_controller to the menu component. I was using a simple element menu, with this in my appcontroller's beforeFilter: function _setLayoutFrontEnd() { $this-layout = 'default'; $this-_loadMenu(); } function _loadMenu() { $categories = $this-Category-find('all',array( 'conditions'=array('Category.ativo'=1), 'order'= array('Category.indexpag'='ASC') )); $this-set('categories',$categories); } With that, I could use the array $categories in my view/elements/menu.ctp. Now I need to pass it to my controllers/components/menu.php. How can I do that? Thanks!!! -- View this message in context: http://www.nabble.com/how-can-I-pass-variable-from-app_controller-to-a-component--tp25530525p25530987.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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: Paginate - order clause is ambiguous!
Did you try like: var $paginate = array ('order' = 'Pages.index'); Andras Kende On Sep 23, 2009, at 12:33 AM, mig_akira wrote: Hello everyone! I'm having a problem here. I have a table Pages, which belongsTo Categories. I'm using an ordenable behaviour, and so both pages and categories have a field called index. Problem is, in my pages_controller, i wrote this: var $paginate = array ('order' = 'index'); And as a result, I receive an error saying SQL Error: 1052: Column 'index' in order clause is ambiguous It must be because both categories and pages have the same field. I cant change this field...so how can I specify that I want to use the index from the Pages table? Thanks!! -- View this message in context: http://www.nabble.com/Paginate---order-clause-is-ambiguous%21-tp25530985p25530985.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Multiple belongsTo relations to the same table fails
This is the error I get: Missing Database Table Error: Database table to_users for model ToUser was not found. Here's the code that prompts it: ?php class Mail extends AppModel { var $actsAs = array('Containable'); var $name = 'Mail'; var $validate = array( 'from_user_id' = array('numeric'), 'from_contact_id' = array('numeric'), 'to_user_id' = array('numeric'), 'to_contact_id' = array('numeric'), 'project_id' = array('numeric'), 'sent' = array('date'), 'subject' = array('notempty') ); var $belongsTo = array( 'FromUser' = array( 'className' = 'User', 'foreignKey' = 'from_user_id' ), 'FromContact' = array( 'className' = 'Contact', 'foreignKey' = 'from_contact_id' ), 'ToUser' = array( 'className' = 'User', 'foreignKey' = 'to_user_id' ), 'ToContact' = array( 'className' = 'Contact', 'foreignKey' = 'to_contact_id' ), 'Project' = array( 'className' = 'Project', 'foreignKey' = 'project_id' ) ); } ? And I already read this: http://book.cakephp.org/view/851/Multiple-relations-to-the-same-model My code seems to comply. It's just not working. Any ideas? --~--~-~--~~~---~--~~ 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: Model update problems
Try changing this line: $this-data['new']['thumb_url'] = $thumb_url;). into: $this-data['YourModelNameHere']['thumb_url'] = $thumb_url;). In case it doesn't change anything, please provide more information, code (controller and model), table definitionsetc. so we have a chance of understanding what may be your problem. Enjoy, John On Sep 23, 6:37 am, Matias_castro mattias.cas...@gmail.com wrote: Hi everyone! I had a running simple application in wich you were able to see images in an image gallery. The problem started when I tried to add a Thumb image. I changed the model in my database by adding a new column 'thumb_url' so I could save the thumb address of an image. The thing is that I can't get to save nor read anything in/from that new column (I'm doing exactly the same than before but with one extra line: $this-data['new']['thumb_url'] = $thumb_url;). Is there any other thing that I should do to force cake to recognize that new column?? I would really appreciate some help here!! Thanks a lot! --~--~-~--~~~---~--~~ 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: Multiple belongsTo relations to the same table fails
check your model User what is the table name that you have define in 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Paginate - order clause is ambiguous!
Try this: var $paginate = array ('order' = 'Page.index'); Lapinski mig_akira wrote: Hello everyone! I'm having a problem here. I have a table Pages, which belongsTo Categories. I'm using an ordenable behaviour, and so both pages and categories have a field called index. Problem is, in my pages_controller, i wrote this: var $paginate = array ('order' = 'index'); And as a result, I receive an error saying SQL Error: 1052: Column 'index' in order clause is ambiguous It must be because both categories and pages have the same field. I cant change this field...so how can I specify that I want to use the index from the Pages table? Thanks!! -- View this message in context: http://www.nabble.com/Paginate---order-clause-is-ambiguous%21-tp25530985p25530991.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---