Re: Tip: FormHelper can create field names like Model[][field]
Thanks for replying Nate. I had a feeling it was a bit or a rouge trick. My suggestion is to see if Form Helper can pick out double dots without breaking anything. Model..field At first glanse it looks like this happens in Helper::setEntity(). /Martin On Dec 10, 5:21 am, Nate [EMAIL PROTECTED] wrote: Hey Martin, interesting trick. This isn't technically sactioned by the API, and could at some point change, but I agree that there needs to be a way to do this, so we'll look at formalizing one in the future. On Dec 8, 10:26 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I may have added it to the manual... not sure since it has been acting a bit strange today and the post timed out. I will check later to see if my edit was submitted. On Dec 8, 2:59 pm, dr. Hannibal Lecter [EMAIL PROTECTED] wrote: Sweet! Thanks for sharing this, it should probably be added to the official manual or something.. On Dec 8, 2:14 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, This is just a small thing but I did not find a mention of it in the manual. I found this out today, after a few years of using Cake :) I want a form input to have the name Modelname[][fieldname] so that I can post an array of fieldname values. The manual only mentions creating these hard coded as Modelname.0.fieldname = Modelname[0] [fieldname] and then incrementing the number. The reason I like the empty version is that is makes for a lot simpler javascript when I want to create these additional fields on the fly in the GUI and don't know how many I will need at the time of rendering the form on the server. Then I tried this (half by accident): $form-input('Modelname. .fieldname'); // notice the space between the dots Voila! The form has the empty space in the field name but Cake creates the array of values just the way Iike 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Email Attachments with MIME/Support? PDF is not showing up?
Hi Louie, Content-Type: pdf; name=Solutions.pdf I believe there is no mime type called pdf. The normal mime type for pdfs is application/pdf. This may be all that is messing up things for you. It is a bit strange that your pdf has this mime type since Cake's EmailComponent looks to output a simple application/octet-stream which basically tells the receiving end Binary data... you figure out what it is! So yoyr problem may be that Yahoo has problems with generic attachments... but that is also a bit strange since they are not exactly a recent startup, new to the web :) Hmm.. This looks kinda simple, but does CakePHP has this feature? where I could tell that this is base64? I checked the API and I could not find any. Only a header() option. You can simply check that is is a correct base64 by copying the data and pasting it into a string and running it through base64_decode(). You should see a lot od binary crap returned but outputting it to a file from php should yield a working pdf... hopefully. It is a lot simpler with images since they usually contain an readable identifier at the beginning of the file... like GIF89a. Pdfs only occasionally contain this kind of string. If you want to try yet another package: I have used the PEAR Mail_Mime package with success. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Ajax form FIELDS validation :-) How to?
I also have this problem... On 27 Nov, 20:48, Anna P [EMAIL PROTECTED] wrote: Hello! I have a register form with several fields, which I want to validate in real-time usingajax. Let's say that form has 4 fields: login_name, pass, confirm_pass, email. Validation rules in model User are: login - from 3 to 20 letters, pass - the same, email - VALID EMAIL. What I want is to code that kind of form: When user enters login_name, theajax-observeField calls action with validating login_name field. When I enter login_name and go to another field (or better - without clicking outside the input),ajaxvalidates that field and puts either tick or cross image with error message, if field didn't pass validation. I want to validate each field without submiting the form. I tried this way: form view: ?php echo $form-create('User',array('url'='/users/register'))? ?php echo $form-text('login_name',array('id'='login_name'));? ?php echo $ajax-observeField('login_name',array('url' = '/ users/verify_field/login_name','update' = 'login-error')); ?br/ span id=login-error?php echo $form-error ('login_name','Wrong login');?/span ?php if(isset($login_error)):?span class=error-message? php echo $login_error;?/span?php endif;?/div div class=clean/div (the same with other fields, instead login_name there is: pass,confirm_pass,email). function verify_field in controller: function verify_field($field) { $this-layout = 'blank-nohtml'; //blank html if(!empty($this-data['User'][$field])) { $this-User-set($this-data); if($this-User-validates() !($field=='login_name' $this-User-find(login_name='.$this-data['User']['login_name'].'))) { $img=tick; } else { if($field=='login_name' $this-User-find(login_name='. $this-data['User']['login_name'].')) { $this-set('login_error',ERROR_LOGIN_USED); } $this-validateErrors($this-User); $img=cross; } $this-set('img',$img); } } verify_field view: ?php echo $html-image('icons/'.$img.'.png')?nbsp; ?php echo $form-error('login_name',ERROR_LOGIN);? ?php if(isset($login_error)):?span class=error-message?php echo $login_error;?/span?php endif;? But this is validation for only one field. How to make it better? And the most important question: when I verify filed like this, I do get correct image (tick if validation passed, cross if not), but the $form-error doesn't show anything if the field didn't pass validation. For any help I would be very greatful. If you know anyajaxform field validation tutorials - let me know. Kisses :-) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Performance crash moving to 1.2 from 1.1?
I'm using debug mode 1, and I've even tried production mode in cake 1.2x and the performance is still poor. I ran xdebug on the code and it appears to be a group of functions really sucking up time: Folder-read = 19.15% (591 calls) Folder-__tree = 9.12% (590 calls) php::array_merge = 8.71% (1348 calls) Folder-slashTerm = 7.69% (3413 calls) Folder-addPathElement = 4.42% (3312 calls) php::preg_match = 3.81% (12008 calls) That's like 51% of runtime.. On 8 Dez., 19:23, mark_story [EMAIL PROTECTED] wrote: Well testing times in debug mode is not really representative of performance. The debug mode in 1.2 is purposefully more heavy than in 1.1. It does a lot more work each request. I would try some benchmarks with debug off. Apache AB can help in this area. -Mark On Dec 8, 9:19 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I've written a very small test setup using cake 1.1... it works turning out excellent numbers: /html!-- 0.0731s -- Then I noticed that 1.2 should be released at some point and thought it might be better to start with it.. I ported my code over.. ran the exact same page and am getting some terrible numbers? /html!-- 0.4523s -- - I've got an app_controller, which does a bit of extra processing (but the same file exists for both implementations), a route setup, and a controller/action for the route. Could there be anything that's configured wrong and throwing off the performance so much on the same code? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Performance crash moving to 1.2 from 1.1?
Chmoded those dirs, and cake is creating some tmp files there now.. Profiled again .. in production mode with same results ;( Any other suggestions where to look? Thanks. On 9 Dez., 11:28, AD7six [EMAIL PROTECTED] wrote: On Dec 9, 11:10 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm using debug mode 1, testing performance in debug mode is at best an interesting afternoons pissing about :). and I've even tried production mode in cake 1.2x and the performance is still poor. I ran xdebug on the code and it appears to be a group of functions really sucking up time: Folder-read = 19.15% (591 calls) Folder-__tree = 9.12% (590 calls) php::array_merge = 8.71% (1348 calls) Folder-slashTerm = 7.69% (3413 calls) Folder-addPathElement = 4.42% (3312 calls) The above indicates the results are either from profiling in debug mode OR because your tmp dir is not (recursively) writeable. php::preg_match = 3.81% (12008 calls) That's like 51% of runtime.. by my calculations, approximately 98.62% irrelevant too (most likely) :) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM on multiple DB---Please help me
MySql On 9 Dic, 10:17, Mauricio Morales [EMAIL PROTECTED] wrote: What kind of DB are using ? On 8 dic, 20:47, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: How can I do it? On 6 Dic, 10:35, Mauricio Morales [EMAIL PROTECTED] wrote: Hi Marco, I think that you can't do it with official methods, however you can implement this functionality. On Dec 5, 11:27 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have this question that I can't resolve. I hope that someone can help me. How can I set a HABTM relation between table on different DataBase? Many Thanks Marco --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Help with table relationships
Thanks guys! Your advice was definitely helpful --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: sorting records based on combobox selection
It may not look pretty but why not use a simple table of allowed order values? var $order_options = array( array('Alert.created'='DESC'), array('Alert.created'='ASC'), ... ); You can inset the right one using: $order_options [$value_from_combo_box] There is of-course also the option of reordering the data using Javascript but I would only consider this for very limited datasets that do not need paging (or limited enough to be paged using Javascript) in an interface that was already heavily Javascript dependent. For a simple standard web-page reloading from the server is the common approach. /Martin On Dec 10, 7:27 am, Sami [EMAIL PROTECTED] wrote: hi, i have to change paginate order query based on user selection on combo box, How to solve? .This my coding... In controller, ... var $paginate=array('limit'=10,'page'=1,'order'=array ('Alert.created'='DESC')); function index() { $this-Alert-recursive = 0; $this-set('alerts', $this-paginate()); }. In index.ctp : ... select id='order' onchange='...' option value='0' selected Sort by Date Descending/option option value='1'Sort by Date Ascending/option option value='2'Sort by Category/Date Descending/option option value='3'Sort by Title/Date Descending/option /select --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help with table relationships
I'm building a basic CMS and I have a 'users' table that is related to more than one other table. The 'users' table is related to these other tables by a '$hasMany' relationship. I did the bare minimum in terms of setting up my models and databases using the $scaffold feature so I could be sure everything worked before getting in too deep. Cake set everything up for me nicely except for anything having to do with my 'users' table which is related to a bunch of other tables in a $hasMany relationship. I'm pretty new to PHP so I'm not sure if I just have a syntax problem or if PHP doesn't allow one table to have more than one $hasMany relationship. Here is the model code I am having trouble with: ?php class User extends AppModel { var $name = 'User'; var $hasMany = array('Article'); var $hasMany = array('Event'); var $hasMany = array('Post'); var $hasMany = array('Price'); var $hasMany = array('Upload'); } ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Tip: FormHelper can create field names like Model[][field]
Hi, This is just a small thing but I did not find a mention of it in the manual. I found this out today, after a few years of using Cake :) I want a form input to have the name Modelname[][fieldname] so that I can post an array of fieldname values. The manual only mentions creating these hard coded as Modelname.0.fieldname = Modelname[0] [fieldname] and then incrementing the number. The reason I like the empty version is that is makes for a lot simpler javascript when I want to create these additional fields on the fly in the GUI and don't know how many I will need at the time of rendering the form on the server. Then I tried this (half by accident): $form-input('Modelname. .fieldname'); // notice the space between the dots Voila! The form has the empty space in the field name but Cake creates the array of values just the way Iike 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Performance crash moving to 1.2 from 1.1?
I've written a very small test setup using cake 1.1... it works turning out excellent numbers: /html!-- 0.0731s -- Then I noticed that 1.2 should be released at some point and thought it might be better to start with it.. I ported my code over.. ran the exact same page and am getting some terrible numbers? /html!-- 0.4523s -- - I've got an app_controller, which does a bit of extra processing (but the same file exists for both implementations), a route setup, and a controller/action for the route. Could there be anything that's configured wrong and throwing off the performance so much on the same code? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Tip: FormHelper can create field names like Model[][field]
I may have added it to the manual... not sure since it has been acting a bit strange today and the post timed out. I will check later to see if my edit was submitted. On Dec 8, 2:59 pm, dr. Hannibal Lecter [EMAIL PROTECTED] wrote: Sweet! Thanks for sharing this, it should probably be added to the official manual or something.. On Dec 8, 2:14 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, This is just a small thing but I did not find a mention of it in the manual. I found this out today, after a few years of using Cake :) I want a form input to have the name Modelname[][fieldname] so that I can post an array of fieldname values. The manual only mentions creating these hard coded as Modelname.0.fieldname = Modelname[0] [fieldname] and then incrementing the number. The reason I like the empty version is that is makes for a lot simpler javascript when I want to create these additional fields on the fly in the GUI and don't know how many I will need at the time of rendering the form on the server. Then I tried this (half by accident): $form-input('Modelname. .fieldname'); // notice the space between the dots Voila! The form has the empty space in the field name but Cake creates the array of values just the way Iike 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Everybody should download Neutrino CMS !
Here it is, Get it now: http://dsi.vozibrale.com/downloads/categories/view/neutrinocms Are you new to Cake? Forget looking at 200 tutorials... peak at this small materpiece and you will generally learn faster and better. Cake veteran? Stuck on something you are sure Cake can handle but you have never or rarely had cause to find out how? Neutrino sourcecode to the rescue! :) Sometimes I get stuck on something, small or large, syntax or design/ structure wise... each time a look at the source for Neutrino has yielded very helpful information or even a few lines of template code to use. I think I may have had a few too many gingerbread-cookies* today but I think that on sober reflection Neutrino is a great contribution to the community even before installing it and actually using it. * According to Swedish folklore/superstition/tradition... gingerbread- cookies (aka pepparkakor) are supposed to get you into a friendly mood. http://allrecipes.com/Recipe/Pepparkakor-I/Detail.aspx --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: upgrade from 1.2 beta to 1.2RC3
Hi, I tried to replicate your problem by putting a form input into an element. My form still renders as it should no problem with double [Modename] or anything else strange. I did not duplicate you exactly since I used a form I am writing at the moment. But it is not significantly different. My create line looks like this: $form-create('Modename', array('url' = $this- here,'name'='SomeKindOfForm')); Could you have some small spelling error somewhere that causes the problem. Something like: $form-input(' Table.field') or something like that? The only other thing I ca think of to ask is if you close your form? $form-end() It should not affect your problem but you never know. /Martin On Dec 8, 12:25 pm, JermWorm [EMAIL PROTECTED] wrote: In my continuing effort to upgrade an app that is working on a early 1.2 beta of Cake I've now encountered another issue with the $form helper. I have a file called detform.ctp which has a number of fields which is included use php's require in a number of different 'parent' forms. If I use inside detform.ctp: echo $form-input('Table.field') In an editing form rendered from the 'Tables' controller 'edit' action now appears to generate. The form is opened using $form-create('Table') although I also tried $form-create(null) input id=TableTableField type=text value=Myvalue name=data [Table][Table][field]/ snippet of edit.ctp ?php $form-create('Table'); ? div ?php require('detform.ctp'); ? /div I want to specify the table name because I also 'require' the sub-form in a search facility that also accepts fields from other tables - which by the way the id's and names are generated as I would expect - I don't want to get wet i.e. not DRY by making a different copy of the subform that caters to both requirments. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM on multiple DB---Please help me
How can I do it? On 6 Dic, 10:35, Mauricio Morales [EMAIL PROTECTED] wrote: Hi Marco, I think that you can't do it with official methods, however you can implement this functionality. On Dec 5, 11:27 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have this question that I can't resolve. I hope that someone can help me. How can I set a HABTM relation between table on different DataBase? Many Thanks Marco --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Question on localization
Hi I have a question on localization of my application. My application has many service builded on the same CakePHP. Every service is avaible for some language. Now I would have a single file language for every service and not a unique file default.po where there is every thing. How can I set the language management to recovered the right file .po? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
HABTM on multiple DB---Please help me
I have this question that I can't resolve. I hope that someone can help me. How can I set a HABTM relation between table on different DataBase? Many Thanks Marco --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
multiple email validation problem
Hi there, i got a problem with cake, i m using the lastest version. i got a form with 3 email fields. email1, email2, email3. and in my table, i want to record each email. i tried to make a validation rule for email. i got : var $validate = array( 'email' = array( 'valid' = array( 'rule' = 'email', 'message' = 'Please enter a valid email address' ), 'unique' = array( 'rule' = 'isUnique', 'message' = 'This email address has already been used' ) )); but it' doesnt work at all. i think there's a problem with the name of my form fields and the validation. any idea ? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: custom find conditions
you're the man. thx --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
custom find conditions
Hari, I need the following SQL query but can't get it by the array syntax. SELECT * FROM table WHERE ( (ceg_id = 0 AND osztaly_id IN(1,2)) OR (ceg_id = 1 AND osztaly_id = 0) ) I tried many different forms like this for find('all') 'conditions' = array( 'szamla_id' = $szamlaId, 'AND' = array( 'OR' = array( 'AND' = array( 'ceg_id' = 0, 'osztaly_id' = $osztalyok ), 'AND' = array( 'ceg_id' = 1, 'osztaly_id' = 0 ) ) ) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Getting started with themes and static files
If your looking for an easy content management system that you can easily extend upon you might wanna look at wildflower which is a cms built in cakephp wf.klevo.sk Good luck Sean On Nov 27, 2:46 pm, Arthur Pemberton [EMAIL PROTECTED] wrote: On Wed, Nov 26, 2008 at 7:20 PM, Dan Bair [EMAIL PROTECTED] wrote: If you're going to be having a lot of static pages, it may be worth your while to use Cake's Folder and File objects. You can loop through the .ctp files assign the routes dynamically. Here's a quick snippet that will go through all of the .ctp files in the pages directory. This will be in app/config/routes.php App::import( 'Core', 'Folder' ); $path = APP . 'views' . DS . 'pages' . DS; $files = new Folder( $path ); $p = $files-find( '(.+)\.ctp' ); foreach( $p as $file ){ if( file_exists( $path . $file ) ){ $tmp = str_replace( $path, '', substr( $file, 0, (strlen ($file)-4) ) ); Router::connect('/' . $tmp, array('controller' = 'pages', 'action' = 'display', $tmp )); } } This worked very well. Thank you. Do note that this won't recursively get all of the files. You'll need to use the Folder::findRecursive method if you'll be using additional directories for your static pages. All my static html should not go deeper than the root. One additional question: How troublesome would it be to have the 'pages' controller also check the web root for .html files? ie: example.com/pagename - WWW_ROOT.DS.$pagename.'.html' ? -- Fedora 9 : sulphur is good for the skin (www.pembo13.com)- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: retrieve value of a select in the controller
Easiest way to check is load the page, view the source and see what the element uses ak form name=data[site][site_id] then use that to figure out what is sent to $this-data The other solution is throw debug($this-data); in your controller to see whats in it. Good luck Sean On Nov 26, 7:57 pm, pkclarke [EMAIL PROTECTED] wrote: I have an uber-noob question: My view has a select that is not associated with any models: echo $form-select('site_id', array('1'='Site 1', '2'='Site 2'), '1', array('id' ='sites', 'label'='Site:')); How do I get the value of the select from the controller? The most logic solution is: $this-data['site_id'] But that doesn't work. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: find using HABTM relationship
I think I can explain it a little. It did not work because Cake does not get habtm data all in a single query. The condition you set is used for the initial query (which does not reach the User model). Set debug to 2 and check the sql output. You should see two queries (I think) for any normal habtm. This is where containable shines. You can specify conditions further down the associations and they will be used in the correct queries. /Martin On Nov 25, 11:09 am, pkclarke [EMAIL PROTECTED] wrote: Thanks to those who tried to help. I was unable to use find to retrieve the data based on the HABTM relationship. I ended up doing manually: -- //lookup User based on email $user = $this-User-find('first', array( 'conditions'=array('email'=$this-data['User']['email']), 'fields'=array('id') ) ); //lookup SiteUsers associated with the selected User $site_users = $this-User-SiteUser-find('list', array( 'conditions'=array('user_id'=$user['User']['id']), 'fields'=array('site_id') ) ); //compile an array of Sites associated with the User (based on SiteUser) $sites = array(); foreach ( $site_users as $value){ $site = $this-Site-find('first', array( 'conditions'=array('Site.id'=$value['site_id']), 'fields'=array('id','title') ) ); $sites[$site['Site']['id']]=$site['Site']['title']; } $this-set('options', $sites); -- I would be interested in knowing why it didn't work, if anyone knows why. Cheers Paul. On Nov 25, 7:06 pm, AD7six [EMAIL PROTECTED] wrote: On Nov 25, 1:26 am, pkclarke [EMAIL PROTECTED] wrote: I'm a noob to CakePHP and have an issue with find returning results from tables with a HABTM relationship. I have 2 tables that have a HABTM relationship: - Site.id - Site.title - User.id - User.name The HABTM join table is: - SiteUser.id - SiteUser.site_id - SiteUser.user_id The Site relationship is defined as follows: var $hasAndBelongsToMany = array( 'User' = array( 'className'= 'User', 'joinTable'= 'site_users', 'foreignKey'= 'site_id', 'associationForeignKey'= 'user_id', 'unique'= true ) ); I am trying to return Sites related to a given User using find, as follows: $options = $this-User-Site-find('list', array( 'fields'=array('Site.id', 'Site.title'), 'conditions'=array('User.id'='7') ) ); However, I get the following error: Warning (512): SQL Error: 1054: Unknown column 'User.id' in 'where clause' The SQL returned shows the HABTM relationship doesn't seem to be working: Query: SELECT `Site`.`id`, `Site`.`title` FROM `sites` AS `Site` WHERE `User`.`id` = 7 Can anyone shed some light on what I'm doing wrong? See the examples:http://book.cakephp.org/revisions/results/query:habtm/collection:2/la... Cheers, AD --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Problem with cachng
I have this question. In my controller I made a read of a record of a model then I update this record and then I made another read. The problem is that the second read operation returns the same datea of the first read. I think that it depends of the cache. How can I do in the way that the second read doesn't use the cache? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
strange request: store view templates in one location
I have an strange client that just can't get past the fact that view templates are, in his words scattered across so many locations. Is there a way to set up a single folder and a name convention then tell the view where to find the files? For examples, all user templates would be something like user_add.ctp, user_edit.ctp, etc. Then he could edit as necessary. I try to convince him to keep his changes to the layout but he want to tweek every form, etc. He is odd. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: strange request: store view templates in one location
The difference, to the client, is when you have 100+ views in 10 or 15 folders. I prefaced this whole thing with strange request, so I'm just trying to keep a client happy if the solution is not unbearable, that's all. On Nov 20, 9:49 am, AD7six [EMAIL PROTECTED] wrote: On Nov 20, 4:10 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have an strange client that just can't get past the fact that view templates are, in his words scattered across so many locations. Is there a way to set up a single folder and a name convention then tell the view where to find the files? For examples, all user templates would be something like user_add.ctp, user_edit.ctp, etc. What's the difference? views/users/add.ctp views/user_add.ctp --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: strange request: store view templates in one location
Thanks for all the feedback, it was an odd request, but I learned a lot from the replies, I have to admit. In the end, I am going to leave it alone, and he can either live with it, pay more, or go away. I have enough work that his isn't critical, which hasn't always been the case. I'm learning to say no, I suppose. Thanks again for all the helpful solutions, I do like the symlink idea myself and will keep that in my files for future reference. brian --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Tutorial - How make associations between models on different database
Thi is all ok. But If I have this situation: Model A in DB A Model B in DB B Model A belongsTo Model B I make a find on Model A with a conditions on Model B. In this case I get error . How can I do in this case? Many Thanks On 8 Ott, 15:24, teknoid [EMAIL PROTECTED] wrote: The only problem with HABTM is that cake will expect your join table to be in the same DB as the main model. The easy work-around is to make a chain of hasMany/belongsTo in this case. On Oct 8, 9:07 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: David: I can see how that would work for hasMany. But for hasOne, belongsTo and (I think) HABTM Cake joins the tables to get the data in a single query. Does Cake honor useDbConfig in these cases? /Martin On Oct 8, 1:08 pm, David C. Zentgraf [EMAIL PROTECTED] wrote: Set up multipledatabaseconnections indatabase.php.http://book.cakephp.org/view/40/Database-Configuration Configure your models to use the appropriate connection.http://book.cakephp.org/view/435/useDbConfig The associations between models work exactly the same, no extra work needed. On 8 Oct 2008, at 17:06, [EMAIL PROTECTED] wrote: Hi I have read many posts about How make associations between models on differentdatabase but I have not yet understood how can I do this. Can someone explain how I can do this for all type of associations (in particular for HABTM)? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Tutorial - How make associations between models on different database
I have noted from cake core (dbo_source.php) that in generation of the join of the query there is: if ($model-useDbConfig == $linkModel-useDbConfig) { So if databases for model is different the join build is bypassed. On 19 Nov, 11:01, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Thi is all ok. But If I have this situation: Model A in DB A Model B in DB B Model A belongsTo Model B I make a find on Model A with a conditions on Model B. In this case I get error . How can I do in this case? Many Thanks On 8 Ott, 15:24, teknoid [EMAIL PROTECTED] wrote: The only problem with HABTM is that cake will expect your join table to be in the same DB as the main model. The easy work-around is to make a chain of hasMany/belongsTo in this case. On Oct 8, 9:07 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: David: I can see how that would work for hasMany. But for hasOne, belongsTo and (I think) HABTM Cake joins the tables to get the data in a single query. Does Cake honor useDbConfig in these cases? /Martin On Oct 8, 1:08 pm, David C. Zentgraf [EMAIL PROTECTED] wrote: Set up multipledatabaseconnections indatabase.php.http://book.cakephp.org/view/40/Database-Configuration Configure your models to use the appropriate connection.http://book.cakephp.org/view/435/useDbConfig The associations between models work exactly the same, no extra work needed. On 8 Oct 2008, at 17:06, [EMAIL PROTECTED] wrote: Hi I have read many posts about How make associations between models on differentdatabase but I have not yet understood how can I do this. Can someone explain how I can do this for all type of associations (in particular for HABTM)? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
How to set DB config settings automatically based on $_SERVER['HTTP_HOST']?
I have a local test server and a live site that I would like to use the same exact codebase on. To automatically switch the config settings in core.php I do something like this: if($_SERVER['HTTP_HOST'] == 'account.local') { // Local define('PATH_TO_WEBROOT', 'path/to/local/webroot/'); define('ENABLE_EMAIL', false); } else { // Live define('PATH_TO_WEBROOT', '/path/on/live/servers/webroot/'); define('ENABLE_EMAIL', true); } However, how do I do a similar thing with the DB settings? I'd like to do something like this, but I don't know where to call it: if($_SERVER['HTTP_HOST'] == 'account.local') $useDbConfig = 'test'; Thanks in advance! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to set DB config settings automatically based on $_SERVER['HTTP_HOST']?
Nice–Thanks! On Nov 19, 11:07 pm, RyOnLife [EMAIL PROTECTED] wrote: Here's what I do: class DATABASE_CONFIG { var $localhost = array( 'driver' = 'mysql', 'persistent' = false, 'host' = '127.0.0.1', 'login' = '', 'password' = '', 'database' = '', 'prefix' = '', 'encoding' = '' ); var $prod = array( 'driver' = 'mysql', 'persistent' = false, 'host' = '', 'login' = '', 'password' = '', 'database' = '', 'prefix' = '', 'encoding' = '' ); var $test = array( 'driver' = 'mysql', 'persistent' = false, 'host' = '', 'login' = '', 'password' = '', 'database' = '', 'prefix' = '', 'encoding' = '' ); var $default = array(); function __construct() { if([EMAIL PROTECTED]'SERVER_ADDR'] || @$_SERVER['SERVER_ADDR'] == '127.0.0.1'): $this-default = $this-localhost; else: $this-default = $this-prod; endif; } function DATABASE_CONFIG() { $this-__construct(); } } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: self-recursive models
I just get the same, as there are no more models associated =( On Nov 18, 10:00 am, grigri [EMAIL PROTECTED] wrote: What do you get if you set recursive to 3? On Nov 18, 7:53 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, thanks for the reply =) don't see how that matters, but sure ?php class Person extends AppModel { var $name = 'Person'; var $hasAndBelongsToMany = array('Picture');} ? ?php class Picture extends AppModel { var $name = 'Picture'; var $hasAndBelongsToMany = array('Person', 'Album');} ? ?php class Album extends AppModel { var $name = 'Album'; var $hasAndBelongsToMany = array('Picture');} ? So a picture may be of more than one person, and each person appears on many pictures. Each picture may be on different albums, and each album has many pictures. I have the 3 tables for the models and the 2 for the joins. Now, like I told you, when I find() the people with default recursion 1, I get a person and all the pictures associated with that person. When I find() with recursion 2, additionally I get each album of each picture, BUT NOT all the people associated with that picture again. So what I want is the 'sister' persons of a person, the ones that appear on the same picture, but I guess cake isn't doing this to avoid loops or something, which it clearly wouldn't. Help? =S On Nov 18, 1:11 am, the_woodsman [EMAIL PROTECTED] wrote: You should look into/post your model relationships, there are some relevant things in there... On Nov 17, 3:41 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello I wonder if anyone can help me with a specific database design. I have a database with pictures of people. A person may be on different pictures, and a picture may have many people on it (so its a HasAndBelongsTo relation with 3 tables...) My problem is that, on a view of a person, I want to list all the pictures of that person, PLUS all other the people that show up in the same photo! So its hard because if try to find() this person with recursion 2, it will fetch the associated pictures, but not the people, since it already passed by the people table. So I'm getting something like this: Array ( [Person] = Array ( [id] = 1 [name] = Bob ) [Picture] = Array ( [0] = Array ( [id] = 114 [description] = Oh what a nice picture ) [1] = Array ( [id] = 115 [description] = Oh what a lovely picture ) ) ) When actually I need something like this: Array ( [Person] = Array ( [id] = 1 [name] = Bob ) [Picture] = Array ( [0] = Array ( [id] = 114 [description] = Oh what a nice picture [Person] = Array( [0] = Array ( [id] = 2 [name] = Alice ) ) (...) and so on has anyone come across such a problem? How can I get around it? Thank You --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
multiple select tags problem
Hi, I have a select field which is output as part a pagination loop, i.e. foreach ($data as $company):? tr ... other data ... td ?php echo $form-input('accountTypeNames', array('onchange' ='this.form.submit()', 'label' = '', 'options' = array ($accountType_Names), 'empty' = 'Please choose', 'selected' = $company['Account']['account_type_id'])) ? /td /tr ?php endforeach; ? /tr My problem is that I don't know which select has been changed when the onchange event is called. Any help is greatly appreciated. Thanks, Roger. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
self-recursive models
Hello I wonder if anyone can help me with a specific database design. I have a database with pictures of people. A person may be on different pictures, and a picture may have many people on it (so its a HasAndBelongsTo relation with 3 tables...) My problem is that, on a view of a person, I want to list all the pictures of that person, PLUS all other the people that show up in the same photo! So its hard because if try to find() this person with recursion 2, it will fetch the associated pictures, but not the people, since it already passed by the people table. So I'm getting something like this: Array ( [Person] = Array ( [id] = 1 [name] = Bob ) [Picture] = Array ( [0] = Array ( [id] = 114 [description] = Oh what a nice picture ) [1] = Array ( [id] = 115 [description] = Oh what a lovely picture ) ) ) When actually I need something like this: Array ( [Person] = Array ( [id] = 1 [name] = Bob ) [Picture] = Array ( [0] = Array ( [id] = 114 [description] = Oh what a nice picture [Person] = Array( [0] = Array ( [id] = 2 [name] = Alice ) ) (...) and so on has anyone come across such a problem? How can I get around it? Thank You --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: self-recursive models
Hi, thanks for the reply =) don't see how that matters, but sure ?php class Person extends AppModel { var $name = 'Person'; var $hasAndBelongsToMany = array('Picture'); } ? ?php class Picture extends AppModel { var $name = 'Picture'; var $hasAndBelongsToMany = array('Person', 'Album'); } ? ?php class Album extends AppModel { var $name = 'Album'; var $hasAndBelongsToMany = array('Picture'); } ? So a picture may be of more than one person, and each person appears on many pictures. Each picture may be on different albums, and each album has many pictures. I have the 3 tables for the models and the 2 for the joins. Now, like I told you, when I find() the people with default recursion 1, I get a person and all the pictures associated with that person. When I find() with recursion 2, additionally I get each album of each picture, BUT NOT all the people associated with that picture again. So what I want is the 'sister' persons of a person, the ones that appear on the same picture, but I guess cake isn't doing this to avoid loops or something, which it clearly wouldn't. Help? =S On Nov 18, 1:11 am, the_woodsman [EMAIL PROTECTED] wrote: You should look into/post your model relationships, there are some relevant things in there... On Nov 17, 3:41 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello I wonder if anyone can help me with a specific database design. I have a database with pictures of people. A person may be on different pictures, and a picture may have many people on it (so its a HasAndBelongsTo relation with 3 tables...) My problem is that, on a view of a person, I want to list all the pictures of that person, PLUS all other the people that show up in the same photo! So its hard because if try to find() this person with recursion 2, it will fetch the associated pictures, but not the people, since it already passed by the people table. So I'm getting something like this: Array ( [Person] = Array ( [id] = 1 [name] = Bob ) [Picture] = Array ( [0] = Array ( [id] = 114 [description] = Oh what a nice picture ) [1] = Array ( [id] = 115 [description] = Oh what a lovely picture ) ) ) When actually I need something like this: Array ( [Person] = Array ( [id] = 1 [name] = Bob ) [Picture] = Array ( [0] = Array ( [id] = 114 [description] = Oh what a nice picture [Person] = Array( [0] = Array ( [id] = 2 [name] = Alice ) ) (...) and so on has anyone come across such a problem? How can I get around it? Thank You --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Determinate layout controller inside app_error.php
I would manage some error of my application that aren't in CakePHP's ErrorHandler and in these errors I need to know the layout On 15 Nov, 16:07, Kyo [EMAIL PROTECTED] wrote: I'm not clear on what you are trying to do but...I'm assuming you already have CakePHP's ErrorHandler class, which captures and handles all cakeError() calls, so why not use 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Determinate layout controller inside app_error.php
Hi I have this question: I would make My Error Handling. I would determinate the layout of the controller that calls my error function inside the error function. How can I do it? Many Thanks Marco --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
problem With remotefunction
hi friends, I m using Remotefunction on radio group, value of that radio button is different. problem is that when i click on particular radio that radio value is pass as argument in may controller action, how can i pass dynamical argument when click on radio. my code like that: ?php $remotePrice = $ajax-remoteFunction( array( 'url' = array ( 'controller' = 'cart', 'action' = 'price',1), 'update' = 'ship','position'='replace' ) ); ? radio group: div id=uk; style=float:leftUKinput type=radio name=remove value= onclick=?php echo $remotePrice; ?//div id=uk div id=europe; style=float:leftEUROPEinput type=radio name=remove value= onclick=?php echo $remotePrice; ?//div id=europe div id=worldwide; style=float:leftWORLDinput type=radio name=remove value= onclick=?php echo $remotePrice; ?//div id=worldwide send me proper solution for that. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
call Remotfunction onload
hi, I want to call remotefunction when my page is load. send me proper guide lines how i call remotefunction when my page is load. can i use JavaScript if yes then how? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to dynamically load controller based on field in database.
Hi Nick, I think you may be going about this in an akward way. You are making a product catalog but using the pages feature of Wildflower for displaying products. I suggest you put your products separate from normal pages. Let the ProductsController handle the products. You should try to see the controllers as the signposts, Airport control-tower... they direct trafic and should try to keep to doing two tings. Deciding what data should be accessed and which view to display. For example, when you ask how to load the ProductsController fron within the PagesController you should be looking for the solution in the Model and the View domains instead. If you want to load product data you need the Product Model, not the ProductsController. Possibly: if ( !empty($data['Page']['modelname']) ) { App::import('Model', $data['Page']['modelname'] ); $model = new $data['Page']['modelname']; //or maybe you have to make it a variable first, I forget. //$model_name = $data['Page']['modelname']; //$model = new $model_name; $more_data = $model-getStuffForPageView(); } (just example code I wrote here in the browser... no error checking, may have mistakes... the usual disclaimers) /Martin On Nov 13, 6:53 am, Nick [EMAIL PROTECTED] wrote: Basically I am using wildflower cms which is built on cakephp. It routes are setup so that / goes to the pages controller. I am building a product catalog and could simply have the urls be / products/category/product-name however I do not want to prepend the controller name in this scenario. Right now I have it so that the product controller from the admin side will insert rows into the pages table as products are created in the products table. Also I created a field in the pages table called controller. By default it is blank however what I want to do is if it isn't blank and for example has Products in it then I want to load the Products controller from within the Pages controller so that it can handle pulling the product images, pricing, etc... I want the controller to be dynamically called. Url structure example desired: /shirts/mens/rockstar-shirt/ - goes to pages controller sees that the controller field has Product and loads product through Product Controller /about-us/ - goes to pages controller and has blank controller field, page rendered as normal Im new to cake but like it so far. Also does anyone know of a good cake cms, wildflower is slow running as localhost. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Ajax response includes entire html layout - why?
Hi, Are you sure you are checking it correctly? Your ajax updates work, you say. But when you check you get the whole layout returned. I would imagine your drop-down looking pretty strange with a full html layout in it. isAjax has always worked fins for me. If you had forgotten to include RequestHandler you would se a big fat error on every page so I doubt that is the problem. Try the quick double-check. Just comment out those lines. If they don't work the ajax should continue to function well without them. If your ajax starts having problems then it's Firebug messing with you. Hopefully that is all it is. /Martin On Nov 13, 9:55 am, keymaster [EMAIL PROTECTED] wrote: I use $ajax-observeField() to update on the change of a dropdown. Don't know why I never used Firebug Net option to check the response (I guess because the ajax update is happening fine), but recently I checked and found the response includes everything - the entire layout and the cake debug html at the bottom of the page. This, despite the following code I put in my appController: if ($this-RequestHandler-isAjax()) { $this-layout = 'ajax'; $this-disableCache(); Configure::write('debug', 0); } Any ideas why the entire layout might still be in the response ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
update filed based on current value
Is there any way to update a row in a table based on current value? I would like to do something like this: UPDATE `test` SET `field` = `filed`+100 WHERE `id` = 1 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help needed for inline WISIWYG editor...
Hi, I need to build an inline wysiswig editor for the project i'm working on. I have tried some editors, but im not being able to extract the typed text using post. Is such a facility built-in in cake ? Can any one help me out in this Thanks in advance --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
accessing other model
I got something strange. Let say I have to models M1 and M2. They have no association. Their controllers are C1 and C2. M1 has a custom method for saving datas. In this saving method I have to call M2-calculate() method. (1) First I tried to add to C1: var $uses = array('M2'); When I did this all my actions dies: Undefined property: C1Controller::$M1 [APP/controllers/ C1_controller.php, line X] (2) The manual says I do not have to add directly the controllers own model to do $uses array, but I did. var $uses = array('M1', 'M2'); In this case I do not get the error above, but when I try to save my datas by my custom method in M1 I get this: Undefined property: M1::$M2 [bAPP/models/M1.php, line Y This line Y is the calling of M2 model's calculate method: $this-M2-calculate(); Am I doing something wrong? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: accessing other model
Models doest not see each other, so I had to use in model1.php's method: App::import('Model', 'M2'); $model2name = new M2(); $model2name-calculate(); --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Change in URL on redirection
Whenever you use the array notation for an url. Cake uses the router to create the url from the parameters given. Even though both marketWeeklies and market_weeklies is interpreted as belonging to market_weeklies_controller.php only one of them is the correct one created by the router. And that is the one with the underscore. marketWeeklies == MarketWeekliesController market_weeklies == MarketWeekliesController But only: MarketWeekliesController == market_weeklies Since I don't know what myspace and spiceboard refers to, I can't really comment on why they change. Are they plugins? prefixes? But the solution is most likely in the router configuration. /Martin On Nov 12, 7:37 am, Cjo [EMAIL PROTECTED] wrote: Hi all, I am new to this part and have one problem - well not a problem, doubt actually as for me the application is working fine. Well I have an URlhttp://localhost/myspace/marketWeeklieswhich is associated to a model market_weekly and controller market_weeklies_controller. After submitting the page and saving I am redirecting the page by $this-redirect(array('action'='index')); This is also works fine and gets redirected as intended. But my url total changes 2 http://localhost/spicesboard/market_weeklies. Can any one clear my doubt. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Can CakePHP do what I need...
Sorry for the late reply. I've been running between meetings for a few days. Say that a Question has a field called type. In your model you could use that key to help in stats calculation and even storage. In your views you could select the correct element based on that key: echo $this-element('form_'.$data['Question']['type']) If you have a big if-else clause you can almost always do without it. If you have some other data related to each type. Store it in an array and call it like this: $some_data = $this-type_data[$data['Question']['type']] If you need to Store the answers in a different table for each type of question: $model_name = $data['Question']['type']; $this-$model_name-findBySomething(...); /Martin On Nov 8, 1:00 am, pgraju [EMAIL PROTECTED] wrote: Thanks for the reply! To choose the correct gui element, I would, in the view (not the controller), use the same logic that sets which type of question it is for the model side of things. I'm not sure what you mean by this, would I put in conditional steps in the view i.e if model_says textbox then do textbox else if model_says scale_1_5 then do scale_1_5 else if Would you set something like that up in the view? I might put together a tutorial on this as well if I can finally get it going :) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: renderAction performance
I am also always on the lookout for a replacement for requestAction in this context. A tip to improve speed is: Don't use requestAction with an action that renders. An action that returns data or simply echoes some string is faster. On your recorded time: You are timing that in Windows aren't you? I don't like to speak ill of Microsoft (well actually...), but there has been a few threads here recently about people noticing very slow performance when running a development setup in Windows. I have no idea why it would be that slow. It does seem to affect Cake 1.2 more than other frameworks or even Cake 1.1 from what I read. Like this thread from last week: http://groups.google.com/group/cake-php/browse_thread/thread/7458faf11365ea7b/ It would be a great service to the community if one of you guys running Windows figured out what causes it. Are you running WAMP, XAMPP, IIS, native Apache or something else entirely? /Martin On Nov 12, 2:07 pm, Pizgin [EMAIL PROTECTED] wrote: Hi! This is action renderPerformance: function renderPerformance() { $time_start = getmicrotime(); for ($i=0;$i50;$i++) { $this-requestAction('/menus/action1',array('return')); } $time_end = getmicrotime(); $time = $time_end - $time_start; print Time: $time sec.br/; return null; } Action MenusController::action1 - empty, view file action1.ctp - empty. OpenBrowser at url 127.0.0.1/test/renderPerformance Output: Time: 11.1430029869 sec. AMD Athlon(tm) 64 X2 Dual Core Processor 4400+, 1GB RAM 11 seconds at drawing a 50 blank items. Duty. How can carry out another collaboration between plug-ins? Thank you. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: renderAction performance
A small example: function action1() { $this-autoRender = false; echo 'Output someting. I use this method for cron situations'; return 'Return something instead, if this is for a normal request'; } $this-requestAction('/menus/action1',array('return')); On Nov 12, 2:34 pm, Pizgin [EMAIL PROTECTED] wrote: A tip to improve speed is: Don't use requestAction with an action that renders. An action that returns data or simply echoes some string is faster. Please, show small example. My OS: Ubuntu 8.04, Apache 2.2.8. On 12 нояб, 16:29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am also always on the lookout for a replacement for requestAction in this context. A tip to improve speed is: Don't use requestAction with an action that renders. An action that returns data or simply echoes some string is faster. On your recorded time: You are timing that in Windows aren't you? I don't like to speak ill of Microsoft (well actually...), but there has been a few threads here recently about people noticing very slow performance when running a development setup in Windows. I have no idea why it would be that slow. It does seem to affect Cake 1.2 more than other frameworks or even Cake 1.1 from what I read. Like this thread from last week:http://groups.google.com/group/cake-php/browse_thread/thread/7458faf1... It would be a great service to the community if one of you guys running Windows figured out what causes it. Are you running WAMP, XAMPP, IIS, native Apache or something else entirely? /Martin On Nov 12, 2:07 pm, Pizgin [EMAIL PROTECTED] wrote: Hi! This is action renderPerformance: function renderPerformance() { $time_start = getmicrotime(); for ($i=0;$i50;$i++) { $this-requestAction('/menus/action1',array('return')); } $time_end = getmicrotime(); $time = $time_end - $time_start; print Time: $time sec.br/; return null; } Action MenusController::action1 - empty, view file action1.ctp - empty. OpenBrowser at url 127.0.0.1/test/renderPerformance Output: Time: 11.1430029869 sec. AMD Athlon(tm) 64 X2 Dual Core Processor 4400+, 1GB RAM 11 seconds at drawing a 50 blank items. Duty. How can carry out another collaboration between plug-ins? Thank you. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: acess url only from email
You may also want to take a stab at some kind of redirection table and a custom dispatcher. Its a little out of the box but it would provide you with a very strong system for keeping the urls one time only. First identify the link you want to go to and put it in a var then run the current date and time through some hash with salt (I would use Auth's password member for this but thats just for convenience) and insert them into a table in the DB. Create a controller like onetime or something (I'm not very clever with names) then pass it the param of the hash of the time. Do a lookup to get the URL that they should be looking at and use requestAction (gasp!) or another similar trick to render the page. When you're done rendering remove the entry in the table and the link is dead. Just a thought. Sincerely, ~Andrew Allen On Nov 12, 10:17 am, Marcus Silva [EMAIL PROTECTED] wrote: You did not understand it, did you? The referer will always be your own domain if the hash in the email validated, since you will be redirecting the user to that page. Consider this: A user register for a website and get a confirmation link. The link in the email points to: http://www.yourdomain.com/confimation/email_hash After the email hash has been validated you send the user to another page on your site. In that other page you check if the referer is (yourself) your own domain (http://www.yourdomain.com/confimation/email_hash). Just make sure you do not link to that page from anywhere in your site. If you know a better solution then use it and share with others as well. Maybe you will get it now. On Nov 12, 4:40 pm, Smelly_Eddie [EMAIL PROTECTED] wrote: That still does not prevent a user from sharing the original url in the email. Anyone that visits the first page could see the second. It seems like this is a moot point if you use authentication or email tickets, which would be a much more sound approach. Any solution you may come up with will not be secure since there is no unique way to identify the source as an email. Some web based email will show the referrer as the provider (gmail, yahoo) but client based applications (thunderbird or outlook) will have a blank referrer. -EW On Nov 11, 4:16 pm, Marcus Silva [EMAIL PROTECTED] wrote: Hi, I am not sure if I got your question right, but if I did you might be ok doing the following: Create an email hash key like Jon Bennett suggested, when the user comes back to your site take make the user go to a url on your site where you can check the hashed value, then send the user to another page, in that page check if the referer ($this-refefer()) was the page the user visited originally via the email link, only send the user to this page is the hash key validates. That should work Hope it helps Cheers Marcus Another way On Nov 11, 8:38 pm, Jon Bennett [EMAIL PROTECTED] wrote: Yes i thought about this approach. But problem is that i need to make access only through email, without restrictions in visit count. In that case don't check for a key's count, jsut allow it. Still use a key though, ideally random per email sent out, something like: $key = substr(md5($user['User']['name'].$user['User']['email']), 0, 20); Only a really keen individual will bother trying to guess your hash key, so only valid urls will work. I don't see how you can stop people from passing the urls around though if they can be used more than once. You can spoof the referrer, so I really don't know how you could police it effectively. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to validate the empty fileds in cakephp
Do I understand you correctly: You have set validation rules in the model. You have a form in your view but your view does not show the errors for each field in your form. First, add some error texts to your model. For example: 'mark1'=array( 'rule'=VALID_NOT_EMPTY, 'message'='Field cannot be empty' ) Then make sure you are calling $form-input() in your view (and not $form-password or one of the other named inputs). Download and take a look at one of the available projects using Cake. Like Neutrino CMS for example. It is fairly small and very clearly written. You can compare the validation codee there with your own and maybe see something you have missed. http://dsi.vozibrale.com/articles/view/neutrinocms-0-1-beta-has-been-released /Martin On Nov 12, 12:31 pm, sun [EMAIL PROTECTED] wrote: hello David can u give some related ideas how to solve that problem any other validation function will be add in controller section? by sundar --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
controller
hi, I have may function in controller, i create view for all function like class cartcontroller extends AppController { var $name= 'carts'; var $uses= array('carts','products','categorys'); function Add() { } function Edit() { }function Delete() { } } My question is that :: 1) it's necessary to crate view for every function ? 2) if i don't required view for delete function then what i have to do? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Counting views of cached pages
Another, more cake based way of doing this, would be to use a beforeFilter, and set the (broadly undocumented at present): var $cacheAction = array('duration'='1 day','callbacks'=true); in your controller. This will add calls to the before filter in your cached page. However, note that you'll have to be careful about any other work done in the beforeFilter and any Components you load, as all these will be initialised as well. Simon http://www.simonellistonball.com On Nov 9, 2:21 pm, Dave J [EMAIL PROTECTED] wrote: This may not be the cleanest solution, but here goes. It's a sort of 'web-bug' approach. You could have an action in your controller (or a separate controller dedicated to statistics) which will do the counting for you, and then invoke it with an img tag in the view. So for example, you can have /articles/addviewcount/article_id which would echo the contents of an empty gif image. And then in the view, you can put something like img src=/articles/addviewcount/1234 width=1 height=1 That way, the addviewcount action will be called, regardless if the view was cached or not. Just remember to turn off view caching for the addviewcount action. On Nov 9, 12:05 pm, Filip Camerman [EMAIL PROTECTED] wrote: In some controller actions I do an UPDATE table SET nviews = nviews + 1 WHERE id = '{$id}' to keep track of how often the page gets viewed (for each record). Now I want to cache some of these actions, and I was wondering what would be the best way to keep counting pageviews. The first way I can think of is to put nocache tags in the view around a requestaction that would do the update query, but that would be a dirty way to do it. Maybe something with a before filter? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Calendar with tasks
Hi, I know this is a bit unusual question in this group but I am implementing the project with cake (which I love). I'm trying to crate week calendar with tasks. I have a problem with displaying it in a table of some sort. Let's say I have several tasks. I know start time (hour+minute), end time and title. Now I want to display something like outlook calendar with tasks (www.law.com/images/ charts/outlook_calendar_biz_web.jpg). The thing is that some events will last for several hours and some event may overlap (let's say we have several meetings during the day, but we have to keep doing something else during the whole day). How do I represent this in HTML? I have tried playing with tables and CSS layers, but just can't display it properly. Can anyone give me a hint? I'm sure that I'm not the first one to deal with this problem and I can't think of any elegant solution. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Using Console for Command Line (Cake Shell) Application
You can also used named arguments in cake shells, for example (I've mixed up the obvious order to stress the fact it doesn't matter): $ cake Myshell -argtwo some value -argone another value and in your Myshell code: function main() { $this-out ( argone value = . $this-params['argone'] ); $this-out ( argtwo value = . $this-params['argtwo'] ); } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 is slow (4s...)
Remigijus: Memory usage is not something you should be overly concerned with on a development machine. (which I guess is what you are testing) If you are using WAMP or XAMPP or something like them then you are basically faking a *nix environment for php to run in. This is probably not the most memory efficient setup for CakePHP on Windows. Have you tried running Cake on a more native Windows installation? It is a pain to install (or it was last time I gave it a go) but should run both faster and more efficient than the *AMPs. I tried pasting your memory-snipped into my layout and got back results between 1.3 and 1.5 MB on two different apps. But if I look at the apache processes, each on is between 12 and 20 MB of system memory. My point is that 5MB measured may vary with the type of php installation. I am not knowledgeable about how php measures memory but I can imagine that as a apache module it measures only itself but as a cgi or fcgi process it may include the overhead of the cgi- wrapper. Apache also has a different worker setup for Windows that may affect memory usage. /Martin On Nov 7, 9:09 am, Remigijus [EMAIL PROTECTED] wrote: Well, I found my problem. It's windows. I have put source code on Linux, and results are Memory used with debug set to 1: 4.8 MB Load time: 0.4s, 3-4 sec, 1 sec. To Martin and Teknoid: Can you tell me the memory usage of you sites? I am watching it on layout page inserted line: memory_get_usage() / 1024 / 1024 And by the way, why on windows cakephp uses 5.5 MB memory, same source on the Linux uses 4.8 MB? On Nov 6, 9:40 pm, teknoid [EMAIL PROTECTED] wrote: Just did a simple look up on a random page of my app (1.2 RC3, recent nightly build) There are three models paginated on the page limit=15 rows. Total of 18 queries required to get all data, 2 for pagination of the main Model (with some conditions), 16 for related models... yes they are little selects on hasMany. There are a couple of CSS includes from the view and a few jquery scripts as well. Debug = 2. Total render time: 0.4857s Simple windows XP PC: 2.33GHz Core Duo, ~ 2GB RAM On Nov 6, 1:50 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Ziobe: It sounds like you are having some odd problem with that computer. I am sorry to say I have no idea of what could be the cause. If 1.2 works fine on another computer, then the oldest support answer in the world might be the only way: reinstall. On Nov 6, 12:12 pm, Ziobe [EMAIL PROTECTED] wrote: Just to say that my cakephp project is blank. And even if i try to change the debug, the problem is still here Remigijus: CakePHP 1.2 IS a bit slower than 1.1 in the real-app tests I have done on my own (roughly 10-30%). But since the difference is more pronounced in more complex requests, a lot of that may be that my code is not optimised enough for 1.2 yet. I have one benchmark that disturbs me but that is best left to it's own thread. But I am not experiencing anything like what you describe. A simple blog-like app I built by taking a chainsaw to the code for the bakery is online (http://pensive.eimermusic.com/) with debug @ 1 and it is usually rendering in less than 0.05 sec. And that is still on RC2 (= the reportedly slow version) and not RC3. FYI: It is on a single server (core duo2 2.33GHz, 2GB RAM sata raid10... nothing special) running mysql5, apache2 and php5 from Ubuntu's standard packages. eAccelerator is active but I have not done much else to optimize apache/php. I am only detailing this to give you something to compare to. That server is a home-built garage-server that should be comparable to any normal computer. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Can CakePHP do what I need...
Hi pgraju, I have a few quick suggestions and comments for you. You probably have each question set to a certain type (free text, 1-5, 1-10, A B C...)? To choose the correct gui element, I would, in the view (not the controller), use the same logic that sets which type of question it is for the model side of things. Or, you might want to look at something like the Wizard component in the bakery. It is ideal for surveys as well. /Martin On Nov 7, 2:25 pm, pgraju [EMAIL PROTECTED] wrote: Hi all, To start off here is my idea: I want to build a survey application, users log in and answer (for example) 10 questions all on separate pages, if a user enters below their average an email is sent out. The 10 questions have all different responses i.e. Drop downs, 1-10 or 1-5 scales, Yes/No answers etc. I have been able to build my database model and have got the admin area scaffolding fine however I'm stuck on how I can now build this model into my views for the user to enter data. Would I set up my application to follow URLs i.e.: /questions/view/1/ - Question 1 - Yes/No question /questions/view/2/ - Question 2 - 1 - 5 radio button question etc. The question controllers works out what the type of response the question has and renders using elements appropriately... I think? This is the only way I can think of building this app's views and just wanted to see what other opinions/criticisms are on my method? Or if you have a better idea I would like to hear about it! Thanks in advance! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Loosing passed arguments after validation and redirection to show errors
I am glad it worked out. Those ajax submits can have you scratching your head a lot before you realize what is going on. On Nov 7, 2:43 am, Home Boy Howy [EMAIL PROTECTED] wrote: Ok, I am a complete dork. The reason this wasn't working is because the AJAX submit wasn't going to the ACTUAL action of the form. So getting rid of that parameter of jQuery AJAX form submit it went to the correct form action which allowed the validation process to return to the correct URL and action. Martins tip above was a great help: You could change your forma little: $form-create('Contact', array('url' = $this-here, 'id' = 'sendpage- form')) Thanks Martin!! -Brian On Nov 6, 4:47 pm, Home Boy Howy [EMAIL PROTECTED] wrote: Wow. I did what you recommends and still no love. Thank you for the tip on $this-here syntax. It is still clearing the params on validation. I guess I don't understand what happens during the validation process. I assumed that it would just return the user to the previous URL with all params still in the URL which would then just reset that data variable. What I am trying to do is a similiar thing as a basic old CakePHP generated admin edit form, but instead of passing the controller function the Id I am trying to pass the function a URL string. Just like the edit link passes the edit form the id and sets a hidden form value, I want to do this with a url string. On edit and submit of the form, instead of saving the data I want to shoot of an email to the email addresses added in the form. What is throwing me is the darn validation of this form. -Brian On Nov 6, 1:45 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Howy, You are loosing the agruments since you are submitting the form to / contacts/send_page and not /contacts/send_page/params/here. But you still try to pull sendUrl from the passed params if the validation fails. You could change your forma little: $form-create('Contact', array('url' = $this-here, 'id' = 'sendpage- form')) or not replace the value of $this-data['Contact']['sendUrl'] if the validation fails. I prefer the first alternative. Either way, you need to validate the url passed and handle that in a different way since displaying the form again will not solve that problem. This data should first be validated before even displaying the form and if the url does not pass validation the form should probably not be displayed at all. /Martin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Enhancements to cakephp testing and code coverage
Hey there, thanks for the hard work! The constant that you need to look at is CAKEPHP_UNIT_TEST_EXECUTION. I will check out your diff today. Thanks, Tim http://debuggable.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Session values not updated after an ajax call
Hello guys, I have a view where I use an ajax call to update a session value according to what a user selects, the value is updated in the view but only if I reload the page manually, not when the ajax call is finished. If I debug my session variable in the controller after the ajax call is made, the value is correctly updated, if I print the same value in the view it is not, only when, as I mentioned before, I reload the page manually. Do you have any idea of what's happening, is it a cache issue or something? Any suggestion will be welcome. Greetings! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: is Cakephp 1.2 faster than Code Igniter ?
How are you going to measure the performance? The time it takes to process a request? The time it takes to develop? Are you going to implement caching? Are you going to try multiple datasources (of various types)? I realize that performance is a complicated issue. I'm currently finding out about different performance testing methods. I'm also going to compare features of frameworks and I'm going to measure development time and other factors while coding test application with each of the frameworks. I'll propably run performance tests both with and without caching. Propably only datasource will be MySQL-database. IMO, a real-world app should have the following features: - User registration - Authentication - Database interaction - At least 5 models, which cover various types of associations - Data validation - Security - Session management - Web service API (at least provisioning) - Administrative interface I'm thinking along the same lines, except I'm not sure if administrative interface is essential when comparing performance. -Kalle --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: is Cakephp 1.2 faster than Code Igniter ?
On 5 marras, 19:34, BrendonKoz [EMAIL PROTECTED] wrote: Another issue with benchmarking is that when dealing with OOP, or any code in PHP, TMTOWTDI (There's More Than One Way To Do It)... So, to properly benchmark any framework, one would have to know each framework inside and out to take advantage of all the tricks to increase performance when necessary, and increase development time when not necessary. This is one of the major issues that many framework performance testers have found...they don't know their frameworks as best as possible, or may know one to a varying degree more than another and not make as many allowable mistakes in one over another. It's hard to get a true non-bias performance test, even if you're trying really hard. ;) That is true. However I'm going to use each frameworks helpers and components when available. That way I'll find how significant the trade-off between shorter development time and system performance is? -Kalle --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
SELECT DISTINCT using find('list')
Hello guys, I need a distinct list of items, so that I tried to set this up using the following code, but it's not working: $list = $this-Model-find('list',array('fields' = 'DISTINCT `Model`.`field`', 'conditions' = array(Model.field2 != '-1'),'order' = 'Model.order ASC')); Unfortunately the result query is this: SELECT `Model`.`field`, DISTINCT `Model`.`field` FROM `models` AS `Model` WHERE `Model`.`field2` != '-1' ORDER BY `Model`.`order` ASC Which is not what I need, there's an extra `Model`.`field`, that breaks the query. Do you have an idea of how to get the results I'm looking for? Thanks in advance --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 is slow (4s...)
Ziobe: It sounds like you are having some odd problem with that computer. I am sorry to say I have no idea of what could be the cause. If 1.2 works fine on another computer, then the oldest support answer in the world might be the only way: reinstall. On Nov 6, 12:12 pm, Ziobe [EMAIL PROTECTED] wrote: Just to say that my cakephp project is blank. And even if i try to change the debug, the problem is still here Remigijus: CakePHP 1.2 IS a bit slower than 1.1 in the real-app tests I have done on my own (roughly 10-30%). But since the difference is more pronounced in more complex requests, a lot of that may be that my code is not optimised enough for 1.2 yet. I have one benchmark that disturbs me but that is best left to it's own thread. But I am not experiencing anything like what you describe. A simple blog-like app I built by taking a chainsaw to the code for the bakery is online (http://pensive.eimermusic.com/) with debug @ 1 and it is usually rendering in less than 0.05 sec. And that is still on RC2 (= the reportedly slow version) and not RC3. FYI: It is on a single server (core duo2 2.33GHz, 2GB RAM sata raid10... nothing special) running mysql5, apache2 and php5 from Ubuntu's standard packages. eAccelerator is active but I have not done much else to optimize apache/php. I am only detailing this to give you something to compare to. That server is a home-built garage-server that should be comparable to any normal computer. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
what can I do to speed up bootstrap beforeFilter ?
Hi, I have been migrating an application to 1.2 and partly because of some threads about performance and benchmarking I have done my own comparisons. Loading up a simple login form for my app (just Auth no ACL) 1.1 is 8-10 times faster. 1.2 quickly catches up on more complete requests with a running session and more data. I was wondering of there was something I could do to my application to speed up Cake's initial overhead? I thought it might be some of my code but the time seem to be lost between bootstrap.php and the beforeFilter. Dropping all components does very little so I am guessing that if any time can be saved it has to be in routing or by some opcode caching. My server has eAccelerator running. Is there any experience of problems using eAccelerator (or APC) with 1.2 or anything like that which could explain the difference? Or , maybe I should say is there anything I may have forgotten to do that would make opcode caching work more efficiently on 1.2? I want to be clear about a few things. 1. I am talking about pretty small numbers here. Hundreds of seconds, not minutes. The total overhead on my server is about 0.06-0.08 sec depending on the mood of the server. 1.1 is usually another 0 down at about 0.008 sec. 1.2 is fast but 1.1 is damn fast, which is slightly annoying :) 2. This is not a big problem for this application on this server but I do have another project where the hardware is being pushed a lot more. This is me learning more about optimization. I am not looking to trim away anything in the core to gain speed but if there is something I can do to help the core boot faster I'd like give it a try. As always, any insights shared are greatly appreciated. /Martin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: SELECT DISTINCT using find('list')
I see, I'll try that and post the results, thanks! On Nov 6, 10:36 am, teknoid [EMAIL PROTECTED] wrote: find('list') requires to fields, because it is used to build a select drop down (with value being the id, and option the name usually). You probably need find('all') + Set::extract() ... depending on what you need really. On Nov 6, 10:44 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello guys, I need a distinct list of items, so that I tried to set this up using the following code, but it's not working: $list = $this-Model-find('list',array('fields' = 'DISTINCT `Model`.`field`', 'conditions' = array(Model.field2 != '-1'),'order' = 'Model.order ASC')); Unfortunately the result query is this: SELECT `Model`.`field`, DISTINCT `Model`.`field` FROM `models` AS `Model` WHERE `Model`.`field2` != '-1' ORDER BY `Model`.`order` ASC Which is not what I need, there's an extra `Model`.`field`, that breaks the query. Do you have an idea of how to get the results I'm looking for? Thanks in advance --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: what can I do to speed up bootstrap beforeFilter ?
It does not make much difference to the time either way actually. debug 0 results are more often down around 0.06 and debug 1 is more often around 0.08 or maybe up to 0.1 at times. On Nov 6, 8:42 pm, teknoid [EMAIL PROTECTED] wrote: You have debug at 0, I presume? On Nov 6, 2:35 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have been migrating an application to 1.2 and partly because of some threads about performance and benchmarking I have done my own comparisons. Loading up a simple login form for my app (just Auth no ACL) 1.1 is 8-10 times faster. 1.2 quickly catches up on more complete requests with a running session and more data. I was wondering of there was something I could do to my application to speed up Cake's initial overhead? I thought it might be some of my code but the time seem to be lost between bootstrap.php and the beforeFilter. Dropping all components does very little so I am guessing that if any time can be saved it has to be in routing or by some opcode caching. My server has eAccelerator running. Is there any experience of problems using eAccelerator (or APC) with 1.2 or anything like that which could explain the difference? Or , maybe I should say is there anything I may have forgotten to do that would make opcode caching work more efficiently on 1.2? I want to be clear about a few things. 1. I am talking about pretty small numbers here. Hundreds of seconds, not minutes. The total overhead on my server is about 0.06-0.08 sec depending on the mood of the server. 1.1 is usually another 0 down at about 0.008 sec. 1.2 is fast but 1.1 is damn fast, which is slightly annoying :) 2. This is not a big problem for this application on this server but I do have another project where the hardware is being pushed a lot more. This is me learning more about optimization. I am not looking to trim away anything in the core to gain speed but if there is something I can do to help the core boot faster I'd like give it a try. As always, any insights shared are greatly appreciated. /Martin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Loosing passed arguments after validation and redirection to show errors
Hi Howy, You are loosing the agruments since you are submitting the form to / contacts/send_page and not /contacts/send_page/params/here. But you still try to pull sendUrl from the passed params if the validation fails. You could change your forma little: $form-create('Contact', array('url' = $this-here, 'id' = 'sendpage- form')) or not replace the value of $this-data['Contact']['sendUrl'] if the validation fails. I prefer the first alternative. Either way, you need to validate the url passed and handle that in a different way since displaying the form again will not solve that problem. This data should first be validated before even displaying the form and if the url does not pass validation the form should probably not be displayed at all. /Martin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
access variable in controller
I have set variables in App Controller I want to access that variable in controller? i do like that: $this-set('feach',$this-products-read()); pr($this-feach); --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: is Cakephp 1.2 faster than Code Igniter ?
I'm writing my computer science masters thesis about PHP-frameworks. All performance tests I've been able to find use hello world- application. I'm planning to code a test application with few frameworks. What kind of application it should be? What would you think are the essential requirements to get a fair results of each framework's performance? Currently I'm comparing CakePHP, Codeigniter, Symfony and Zend Framework. Do you those are the essential ones? -Kalle On 28 loka, 19:39, mark_story [EMAIL PROTECTED] wrote: On Oct 27, 9:38 pm, teknoid [EMAIL PROTECTED] wrote: Here's a test... Create a file index.html in the web root of your server with the content hello world. Now take any framework and compare the speed it takes to render... the index.html framework beats them all! index.html framework is by far the best clearly! Forget this CakePHP crap, I'm going all index.html framework from now on. /sarcasm I would like to see some development benchmarks as well, that would be interesting. How long it takes to build an example non 'hello world' app in each of these frameworks. Like teknoid said, servers are cheap man months are not. So this benchmark could be more useful for people choosing frameworks. With the example teknoid gave, it would take 16 years of CakePHP hosting to equal index.html framework development time. -Mark On the other hand we can do another test... Take CakePHP and develop a fully functional application with 60 models (or so) in two months. To double it'sperformancewe purchase a dedicated server for $119/month. Or we could write one from scratch in about 4 months (if we're lucky), which means that we've spend 320 extra hours of development time (40 hrs per week * 8 extra weeks) at $75/hr.. which translates to extra $24,000 spent on the project. I'm not really sure, which one of these tests is more pointless ... but to me it seems silly to measure a framework'sperformancewith hello world. On Oct 27, 12:04 pm, wahyu setianto [EMAIL PROTECTED] wrote: I have read inhttp://www.yiiframework.com/performance, it is true ? i know that CI is faster than cakephp because CI is not using OOP actualy -- Octopus East Java Baker --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Changing the Auth-loginRedirect based on value in user model
Hi all, I have a simple app that needs to have 2 types of users, normal users and admins. I have got the Auth component working great and has the entire site requiring log in etc, but I want to redirect users that are admins to the admin route sections upon login. I have this in my app_controller: function beforeFilter() { $this-Auth-allow('display'); $this-Auth-logoutRedirect = array(Configure::read('Routing.admin') = false, 'controller' = 'users', 'action' = 'logout'); $user = $this-Auth-user(); //debug($user); if($user['User']['admin'] == 'n') { $this-Auth-loginRedirect = array('controller'='orders', 'action'='index'); } else { $this-Auth-loginRedirect = array('controller'='orders', 'action'='index', 'admin' = true); } } And while it doesnt throw errors it seems to behave wierdly - it redirects to the /admin route regardless, but if I go back in my browser and login again it redirects to the correct page! Has anyone tried to do this before? Any suggestions what I may be missing? TIA, d. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Hello friends,
Myself jack, I m new to programming and with cakephp I m even more new.I went through this site cakphp.org, Its quite helpful, But I m not able to think logical at times as to why we use few things..Now i m improving, But need to work a lot on it.I m helpless, And I get confused in between what and how to do??Not confiden enough.Do provide me a good tutorial material and examples links or information so tat i can master over cakephp and dominate to its development. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Extending built-in Auth Component?
Hi Nathaniel, Did you get your AuthComponent extension working? If so, would you like to share it? :) I've been looking for LDAP authentication in cake for some time, but I'm not sure how to get to it. -- alx --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Before filter, the session falls
There has been scattered reports from people experiencing unpredictable loss of sessions. I have noticed this myself at times. What I understood about it was that the problem stems from the level of security set in Cake's config. When it is set too high you can accidentally be caught hacking your own app so to speek. The phrase too high is definitely poorly chosen and should not be taken to mean that most of us should lower our default security settings. An example of what can happen: You have a page doing periodical ajax calls. You click a link during the time Cake is processing one of these ajax calls. Your request will be parallel with the ajax call and therefore caught in the security check. Or at least something roughly like this. I have not had a detailed look inside Cakes security and session classes. I have also noticed this happening when uploading files and doing 2-3 redirects after each-other. Those are unfortunately hard to reproduce at will. /Martin On Nov 3, 10:08 am, mcphisto [EMAIL PROTECTED] wrote: Well, I've a big big problem with two applications of mine. I use an authentication method made with before filter. The problem is that, after a login it works correctly. Then, without a reason, the application seems to loose the session and brings me back to the login form. For this reason, I really can't understand what happens and when. Is there a way to produce a log for the application? Or otherwise, how I can unserstand what happens? That's the code in app_controller.php: function checkSession() { // If the session info hasn't been set... if (!$this-Session-check('Dealer')) { // Force the user to login $this-redirect('/dealers/login'); exit(); } } And this in dealer_controller.php function login() { //Don't show the error message if no data has been submitted. $this-set('error', false); // If a user has submitted form data: if (!empty($this-data)) { // First, let's see if there are any users in the database // with the username supplied by the user using the form: $someone = $this-Dealer-findByUsername($this- data['Dealer']['username']); // At this point, $someone is full of user data, or its empty. // Let's compare the form-submitted password with the one in // the database. if(!empty($someone['Dealer']['username']) $someone['Dealer']['password'] == $this-data['Dealer']['password']) { // Note: hopefully your password in the DB is hashed, // so your comparison might look more like: // md5($this-data['User']['password']) == ... // This means they were the same. We can now build some basic // session information to remember this user as 'logged-in'. $this-Session-write('Dealer', $someone['Dealer']); // Now that we have them stored in a session, forward them on // to a landing page for the application. $this-redirect('/customers/index_search'); } // Else, they supplied incorrect data: else { // Remember the $error var in the view? Let's set that to true: $this-set('error', true); } } } function logout() { // Redirect users to this action if they click on a Logout button. // All we need to do here is trash the session information: $this-Session-delete('Dealer'); // And we should probably forward them somewhere, too... $this-redirect('/dealers/login'); } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Another pagination problem
This has been covered numerous times before. http://groups.google.com/group/cake-php/search?q=search+pagination; If you have a specific issue related to this then please ask again. /Martin On Nov 3, 4:58 am, 0x1A4 [EMAIL PROTECTED] wrote: Hi all im relatively new to Cakephp.Currently im creating a web app for our in house usage to track and monitor tenders.My problem right now is im creating a search function.Whenever user submit strings to the search query it all went well.However the problem occur on pagination when the search result is more than 1 page.If the user navigate to the 2nd page it will ignore all the search query.Below is the pastebin of my code.Sorry for my bad english Controller codehttp://bin.cakephp.org/saved/39125 View codehttp://bin.cakephp.org/saved/39126 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: database is utf-8, page is utf-8, but i get weird characters
There is also an application-global encoding setting in config/ core.php On Nov 2, 8:33 pm, Dave J [EMAIL PROTECTED] wrote: Not sure why it would show up as a question mark when you generate the form with the helper, however, when connecting to the database, make sure you set the encoding as well. var $default = array('driver' = 'mysql', 'host' = 'localhost', 'login' = 'username', 'password' = 'pass', 'database' = 'database_name', 'encoding' = 'utf8' ); On Nov 2, 2:32 pm, bartvh [EMAIL PROTECTED] wrote: My MySQL5 database is encoded in utf-8, and the page is as well (which is declared in the html meta tags), however when I generate a select field with the form helper, an uncommon character (é to be precise) shows up as a question-diamond in firefox. if i manually set firefox to use western (iso-8859-1) the character shows up fine. what goes wrong here? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Building Tagging feature in my site
This does not serve the purpose because tagging needs to be implemented on all the 3 types of entities : Posts, Teachers and Books . On Nov 1, 11:15 pm, Anupom [EMAIL PROTECTED] wrote: Please find my suggested db design below, tags: id, name types: id, name posts: id, name teachers: id, name books: id, name, type_id books_tags: id, book_id, tag_id All ids are auto increment primary fields. So if, the book with (id, name, type_id) = (6, 'Bookname', 2) has two tags with (id, name) = (11, 'Chemistry') (23, 'Grade A'), then the entry in the books_tags(book_id, tag_id) table for this will be - (6, 11) (6, 23) . Also read this page from the dochttp://book.cakephp.org/view/24/Model-and-Database-Conventions -- Anupom Syamhttp://syamantics.com/ On Sat, Nov 1, 2008 at 8:42 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi All, I am trying to build a tagging feature in my site which is a community site for a school. In my site, I have various entity types like : Blog Post, Teacher, Book . Every entry for these entities will have tags associated with it . So, a tag may belong to one or more items of different entities. In a normal core PHP project, I would have designed tables for this in the following manner :- 1) tags : tag_id, tag_name . 2) entity_types : entity_type_id, entity_type_name . [(0, Posts), (1, Teachers), (2, Books)] 3) posts : post_id, post_name . 4) teachers : teacher_id, teacher_name . 5) books : book_id, book_name 6) entities_tags : tag_id, entity_type_id, entity_id . So, if a book (entity_type_id = 2) with book_id = 6 has 2 tags (tag_id, tag_name) : (11, 'Chemistry') (23, 'Grade A') , then the entry in entities_tags for this will be : (11, 2, 6) (23, 2, 6) . I am using CakePHP for my project and I am not able to design the tables in CakePHP for this Tagging Feature. It would be great if people could come up with their suggestions. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
change language of setFlash()
hi, I want to change setFlash message English to franch how can i change language of flash message? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Building Tagging feature in my site
Hi All, I am trying to build a tagging feature in my site which is a community site for a school. In my site, I have various entity types like : Blog Post, Teacher, Book . Every entry for these entities will have tags associated with it . So, a tag may belong to one or more items of different entities. In a normal core PHP project, I would have designed tables for this in the following manner :- 1) tags : tag_id, tag_name . 2) entity_types : entity_type_id, entity_type_name . [(0, Posts), (1, Teachers), (2, Books)] 3) posts : post_id, post_name . 4) teachers : teacher_id, teacher_name . 5) books : book_id, book_name 6) entities_tags : tag_id, entity_type_id, entity_id . So, if a book (entity_type_id = 2) with book_id = 6 has 2 tags (tag_id, tag_name) : (11, 'Chemistry') (23, 'Grade A') , then the entry in entities_tags for this will be : (11, 2, 6) (23, 2, 6) . I am using CakePHP for my project and I am not able to design the tables in CakePHP for this Tagging Feature. It would be great if people could come up with their suggestions. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Question about Data Sanitation in CAKEPHP
If I would sanitaze my input from javascript code? On 30 Ott, 18:57, Gwoo [EMAIL PROTECTED] wrote: The DBO layer handles proper escaping of your data to prevent SQL injection. You do not need to use Sanitize unless you are doing something out of the ordinary. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: An OO question
Well I guess its Halloween so we can expect a few (help) vampires right? hehe! On Oct 31, 4:04 am, Calvin [EMAIL PROTECTED] wrote: Hi all, I am finding difficult to understand why this isn't working... ?php abstract class A { protected static $property = false; # Q1 public static function method() { # Q2 return self::$property; } } class B extends A { protected static $property = true; # Q1 } var_dump(B::method()); It prints False and I expect it to be True... Q1. Does B::$property suppose to overwrite B::$property? Q2. when B::method() is called, shouldn't it return B::$property (even though the method is declared in A)? Q3. Anyways to change the code to work as my expectation? Thanks in advance - Calvin --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Question about Data Sanitation in CAKEPHP
Ok Many Thanks On 31 Ott, 11:29, Dardo Sordi Bogado [EMAIL PROTECTED] wrote: If I would sanitaze my input from javascript code? No, you need to escape whenever you send dynamic content to de user (though the form helper will escape the inputs values), use the builtin h() function. echo h($comment['Comment']['content']); If you want to strip the tags or other bad content and avoid it from beign stored (they will be escaped by the dbo layer but will get inserted in the db anyway) you need to use Sanitize::clean() or Sanitize::stripWhat() where what is any of Tags, Images, Scripts, Whitespace, All. HTH, - Dardo Sordi. On 30 Ott, 18:57, Gwoo [EMAIL PROTECTED] wrote: The DBO layer handles proper escaping of your data to prevent SQL injection. You do not need to use Sanitize unless you are doing something out of the ordinary. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Looking for suggestion to filter data in cakephp
A Mac coming from Obj-C... you must be just a little frustrated with phps OO support :) I put the models I have and a controller method, as an example, in the bin for you to take a look at and laugh at as you please. http://bin.cakephp.org/view/1027493569 The code can be re-factored and improved a lot. I just wrote it in desperate haste a good while ago and have not had a cause to revisit it since. I forgot to put in the fields model (stored the searchable fields and their types). That part will probably be replaced by som automatic schema mapping but in my case I still have is as a table. The model has no special features. For your reference here is the table for that: CREATE TABLE `fields` ( `id` int(11) unsigned NOT NULL auto_increment, `display_name` varchar(255) default NULL, `type` varchar(255) default NULL, `field_name` varchar(255) default NULL, `model` varchar(255) default '', `created` datetime default NULL, `modified` datetime default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 On Oct 30, 5:13 pm, mario [EMAIL PROTECTED] wrote: Thanks Martin. That gave me a bit of an idea of what I'm going to do. And yes I want to know the specific details on how you implemented it. It would also be good if I could see some snippets of your code (model,controller,view) to further understand what you're trying to explain. Btw, I'm actually a mac developer but I'm still new in cakephp. =) On Oct 30, 8:36 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: First I'll admit I did not read through all your code. But I think I get what you are doing. I created a filtering system about a year ago. I wanted/needed something that worked a bit like the find feature in Mac OS X Finder, or in some SQL-GUIs I have used. If you have see this you know what I am talking about. I also needed these to be saved and recalled later. Anyway. I ended up with something that is a lot more streamlined in the controller but with a bit more work done in the Models. Filter is the whole search setup for a particular search. Rule is a single filtering rule. Filter hasMany Rule One Rule can have: - a property to filter - an operator - a value entered by the user End result might be email ends with gmail.com for a single rule. Adding more rules to a Filter would narrow the search using AND. This turned out the be very flexible. A filter can be attached to any other model and do filtering on it. The rule model contained a big data array with different operators (sql fragments) for different types of data. Since humans want to filter numbers differently from email addresses I created a number of these preset custom fragments that could be selected from drop-downs in the gui. The rule model also contained a method for converting the stored parameters (field, match, value) to an sql fragment for a given model. Some examples of fragments: $this-types['Text']['equals'] = '%s LIKE \'%s\''; $this-types['Text']['contains'] = '%s LIKE \'%%%s%%\''; $this-types['Text']['starts_with'] = '%s LIKE \'%s%%\''; $this-types['Text']['ends_with'] = '%s LIKE \'%%%s\''; $this-types['Date']['days_ago'] = 'FLOOR(DATEDIFF(CURDATE(), DATE(%s))) = \'%s\''; $this-types['Date']['weeks_ago'] = 'FLOOR(DATEDIFF(CURDATE(), DATE(%s))/7) = \'%s\''; Each field is mapped to a type. Datetime fields becomes the Date type. Text fields could be set to email or anything but defaults to Text. The filter code was nothing special. The only special method there was getFilterFor($model_name) which gathers the results from each rule. The reason for this setup was partly flexibility and partly the GUI. I really wanted a humane gui. No wildcards or pseudo-sql. Simple selects and meaningful words. Looking back it is not a very difficult setup but it did take some time to come up with the right way to set it all up. I hope that gives you some ideas. Let me know if you want a few more boring details of the implementation. /Martin On Oct 30, 3:43 pm, mario [EMAIL PROTECTED] wrote: Hello everyone, I'm planning to include filters in my new project wherein it will allow the user to filter or show only the information that he/she wants. Of course there would be a search form (textfield,combobox,checkbox, submit button) for this relative to my tables' fieldnames in the database. I've already done this before on my recent project using cakephp. I will post some of my code snippets here for you to make some suggestion and for me to find out if what I'm doing is correct or not. I'm also looking forward on recommendations on how to improve my filtering process (which I'm gonna use on my next project). Here is the code snippet of my controller (I've placed the filters in my index view): --- -- function
How to manage HABTM that is reflexive?
I have a table of users, and I want to make links between users, so each user can have links to one or more other users. I can't see, however, how to set this up in Cake. The linking table has two fields that link to the Users table, but how to I create the correct model? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: HABTM in rc3 need now field id in link table.
Sorry to answer a question with a question... What query would Cake ever need to do to that table where it needed to pick out a single row without knowing the two ids (e.g. article_id, tag_id)? I am of-course talking ab out a clean join table. Not one with extra fields in it. If you make a unique index (or a composite primary key) of the two id fields you prevent duplicate rows and that is all that is needed for that table. If, on the other hand, the table has extra fields (something Cake has previously not supported) and used as a real model, then I certainly see the need for a pk. btw: a composite pk has in my experience never caused any problems. I have used that since before 1.0 went stable. On Oct 29, 8:51 pm, teknoid [EMAIL PROTECTED] wrote: How else would ensure uniqueness of records if cake does not/will not support composite keys? On Oct 29, 3:42 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I don't really agree with the should part. For a standard join table I see no reason for an extra id, and I have not noticed of heard of such a requirement before. Also, when a decision is taken to start requiring a single-field pk in join-tables I would have expected a bit more of a heads-up about it. Any new feature that changes the behavior (not halting on an error but just silently acting differently) of old code will naturally be thought of as a bug by users if there is no clear indication about the changed behavior. About the tests: they are usually the place people get directed to to find out the true implementation of any feature. It is also the standard reply to any bug-report (That the tests pass). So I would not expect them to be out of date in that way. But it is of-course possible. If anyone has link to a document on the change in requirement, I would be grateful. It could be a good read. /Martin On Oct 29, 6:34 pm, teknoid [EMAIL PROTECTED] wrote: Even if those test pass (due to their nature), a primary key column should be created in a vast majority of cases. p.s. It could also be that the tests need to be updated. On Oct 29, 4:34 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Teknoid, you may be right but the fixtures for the tests in the core create loin tables without a pk. E.g: var $fields = array( 'article_id' = array('type' = 'integer', 'null' = false), 'tag_id' = array('type' = 'integer', 'null' = false), 'indexes' = array('UNIQUE_TAG' = array('column'= array('article_id', 'tag_id'), 'unique'=1)) ); /Martin On Oct 28, 3:56 pm, Alexandru [EMAIL PROTECTED] wrote: no no in rc2 this was on manual Recipe HABTM Tag = recipes_tags.recipe_id, recipes_tags.tag_id BUT now they changed in manual and put this Recipe HABTM Tag = id,recipes_tags.recipe_id, recipes_tags.tag_id now i know for sure it is NOT a BUG. TOPIC CLOSED --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: 1 Cake file, multiple apps / cake bake
First a little typo: PATH=$PATH:/usr/local/bin:/Users/myUserName/Sites/Cake/1.2.x.x/cake/ console/ Remove the last cake. The path should point to the folder not the file. Do I understand you correctly? You want to have this kind of structure: cake - the root cake - where cake's core is app1 - one of your apps app2 - another app app3 - yet another app I do two things for these apps to work: 1. make a dns entry with a fake domain name in /ets/hosts 127.0.0.1 app1.site 127.0.0.1 app2.site 127.0.0.1 app3.site 2. add a vhost entry for each one in one of apache's config files. I use Apples apache installation so I choose to do this in /etc/ apache2/users/martin.conf First this: NameVirtualHost *:80 Then one of these for each site: virtualhost *:80 DocumentRoot /Users/martin/Sites/cake/app1/webroot ServerName app1.site /virtualhost I also have a directory entry to allow override and such things for all folders under cake's root. When it comes to using cake console with these multiple apps I have not found a better way than cake -app /full/path/to/app. I read that cd-ing to an app folder would make the console choose that folder automatically but it hasn't worked for me. Neither has relative path like -app . /Martin On Oct 29, 9:52 pm, gemmes [EMAIL PROTECTED] wrote: Hi All, I have a windows tutorial which shows me how to create 1 cake folder that is used for all CakePHP localhost applications built(using WAMP). I am trying to set this up on my mac. Can anyone point me to a site that shows me this? or Can anyone tell me how to do this? I am trying to get this to work in cake bake app. Also, instead of typing this into terminal: '/Users/myUserName/ Sites/Cake/1.2.x.x/cake/console/cake' I want to type just 'cake I changed my .profile file to this as instructed elsewhere(but not working for me): ## DELUXE-USR-LOCAL-BIN-INSERT echo $PATH | grep -q -s /usr/local/bin if [ $? -eq 1 ] ; then PATH=$PATH:/usr/local/bin:/Users/myUserName/Sites/Cake/1.2.x.x/ cake/console/cake export PATH fi pls help gemmes --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Problem on Modify of AppModel
Hi I have add a function on AppModel (function try()) . With this modify when I try to make find('all') on any model I see that the HABTM of the model are empty if I remove the function try I see that all works fine and the HABTM aren't empty. What kind of problem is this? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem on Modify of AppModel
Sorry I have forget to tell that with debug=2 I can see that the CAKEPHP does the correct SQL query.But I can see nothing On 30 Ott, 10:22, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi I have add a function on AppModel (function try()) . With this modify when I try to make find('all') on any model I see that the HABTM of the model are empty if I remove the function try I see that all works fine and the HABTM aren't empty. What kind of problem is this? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Login Redirect not Redirecting
Try: e($form-create('User',array('action'='login'))); Possibly also: e($form-input('User.username')); e($form-input('User.password',array('type'='password'))); in case the first does not do the trick. I usually define Model.field even when it is not necessary. /Martin On Oct 30, 2:03 am, thatsgreat2345 [EMAIL PROTECTED] wrote: I am having trouble with the redirect, I have manually inserted the username/password values, I have hashed the password with the correct security salt. However when I go to users/login and type in the username and password it does not redirect me to what I have specified in $loginRedirect it just sends me to users/login. However nothing has changed, there is no error message displayed, the password field hasn't been hashed as it usually hashes and if there is an error it shows the hashed password in the password input but it is just the non- hashed password. Any insight would be great. Controller ? class UsersController extends AppController { var $name = 'Users'; var $components = array('Auth'); function beforeFilter() { // $this-Auth-authorize = 'controller'; //$this-Auth-loginAction = array('controller' = 'users', 'action' = 'login'); $this-Auth-loginRedirect = array('controller' = 'users', 'action' = 'index'); $this-Auth-loginError = 'Username or password is incorrect'; $this-Auth-logoutRedirect = '/'; $this-Auth-authError = 'You are not allowed to access this.'; } function index() { } function login() { } function logout() { $this-redirect($this-Auth-logout()); } } ? Model ? class User extends AppModel { var $name = 'User'; } ? View ? if ($session-check('Message.auth')) $session-flash('auth'); e($form-create('Users',array('action'='login'))); e($form-input('username')); e($form-input('password',array('type'='password'))); e($form-end('Login')); ? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Db Design for my first Cake App
At a glance it looks pretty good. A few points and thoughts... most of them not necessary but might be good to have. • created_on and updated_on should loose the _on part to match Cakes conventions and be filled automatically. • You could add created and updated to comments and users as well. • You may want a boolean for the users activated or blocked or whatever you prefer. That way you can easily block users without actually deleting them and also handle email-verification (like every website in the world does) • You may want to have all user data (even those not registered) in the users table. Or in another central table for email and created_by (= name). The email might be a good unique value for such a table. That table would then be linked to users, pois and comments. happy baking! /Martin On Oct 30, 3:13 am, pgraju [EMAIL PROTECTED] wrote: Hi all, I'm trying to create a map mashup using CakePHP for my first Web App with Cake :) But I'm just afraid that I'm not structuring my database correctly... The idea: A simple mashup with google maps which allows people to submit/search points of interest on a map and click on the pointers for address information and to view/add comments. Users don't have to register but there is an option available if they want to. My db tables so far: - pois (point of interests) - id name address1 address2 locality state country lng lat ip_address (should I log this?) user_id comment_id created_by (this is filled out by the user if they do not want to registered) email_address (this is filled out by the user if they do not want to registered) created_on updated_on - users - id username password firstname lastname email_address - comments - id title content created_by (this is filled out by the user if they do not want to registered) email_address (this is filled out by the user if they do not want to registered) ip_address (should I log this?) user_id Have I gone about the right way doing this for a CakePHP app? If not do you mind shedding some light? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with encoding when upgrading to 1.1.20
There is a central application-wide encoding setting in config/ core.php. Make sure you have not forgotten that one. Another basic check is to look at the layout and see what charset is set in the header. (just to make sure) One problem I have seen is that you may think that your old data is in utf-8 when it in fact is not. Possibly the old application connected to the database using latin1 or something despite your efforts. This has happened to me in the past and is not too hard to fix if you can take the database offline for a few minutes. If you connect to the database (console client) and make sure you are using utf8 for the connection (set names utf8 at least for mysql) you can select some data and see if it is displayed correctly in the console. If it is not then your data is inserted as something else (probably standard latin1). If you find that your data is in fact not stored correctly you need to figure out which fields in which tables need converting. That can be the tiresome bit. Start with one field in one table and do some tests with the following queries. The order you put them in and the charsets you select will determine the results. I have put some sample data on my website. If you find this is your problem , you can check it out: http://pensive.eimermusic.com/remember/fixing-existing-data-when-switching-character-set-in-mysql /Martin On Oct 30, 9:21 am, Sjurl [EMAIL PROTECTED] wrote: Hello, The application im developing has just upgraded from CakePHP 1.1.11 to 1.1.20 and that somehow broke the encoding of the data we show the user from the database. When i changed back to 1.1.11 (changing the cake folder) it all worked as intended again. Im trying to use UTF-8 but the page is rendered in ISO-8859-1. The database encoding is UTF-8 and i have put the right meta tag in the main thtml file and allso put in 'encoding' = 'UTF8' in the connection to the database. We are using Postgresql and all the tips i so far have found on fixing this problem seems to be with users using MySQL so im not realy sure if the things i have tried to do are able to fix my problem. Is there anyone who knows where i ought to look to fix this problem, or what might be causing it? It seems that it is something in the core library that has changed between these two builds that are causing it. Best regards Sjur --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem on Modify of AppModel
At a guess I'd say that the function name try might clash with the try, catch features in php5. But I get a big fat error and not your subtle results. Parse error: syntax error, unexpected T_TRY, expecting T_STRING Try renaming the function and see what happens. /Martin On Oct 30, 10:24 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Sorry I have forget to tell that with debug=2 I can see that the CAKEPHP does the correct SQL query.But I can see nothing On 30 Ott, 10:22, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi I have add a function on AppModel (function try()) . With this modify when I try to make find('all') on any model I see that the HABTM of the model are empty if I remove the function try I see that all works fine and the HABTM aren't empty. What kind of problem is this? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem on Modify of AppModel
I find error: If I add in var $name=AppModel; there is the problem Instead If i remove this all works fine On 30 Ott, 11:23, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: At a guess I'd say that the function name try might clash with the try, catch features in php5. But I get a big fat error and not your subtle results. Parse error: syntax error, unexpected T_TRY, expecting T_STRING Try renaming the function and see what happens. /Martin On Oct 30, 10:24 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Sorry I have forget to tell that with debug=2 I can see that the CAKEPHP does the correct SQL query.But I can see nothing On 30 Ott, 10:22, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi I have add a function on AppModel (function try()) . With this modify when I try to make find('all') on any model I see that the HABTM of the model are empty if I remove the function try I see that all works fine and the HABTM aren't empty. What kind of problem is this? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Question about Data Sanitation in CAKEPHP
Hi I would use a systematic method to clean data to insert in DB. I think to use Sanitize::clean function in beforeSave(). Now my question : When I do a research in DB (for example with find) If I don't apply the Sanitize::clean function to the value inside the conditions I don't get the right values.How can I do it? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Question about Data Sanitation in CAKEPHP
Is it someone can help me? On 30 Ott, 12:43, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi I would use a systematic method to clean data to insert in DB. I think to use Sanitize::clean function in beforeSave(). Now my question : When I do a research in DB (for example with find) If I don't apply the Sanitize::clean function to the value inside the conditions I don't get the right values.How can I do it? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Whats the best idea to keep DB under version control or under sync with server?
There are a bunch of tools for a bunch of operating systems (and a bunch of databases). I have only ever used MySQL, so this will concern itself with that db. If you need to keep track of charsets and collations you should choose your weapon carefully. For Mac OS X I have only found Navicat (costs money) to deal with those things fully... and that, only recently after I begged them to implement some missing details. Most other software have partial support or no support at all. Partial is the worst since it will after a few updates create a real mess of settings in your db. If you don't care about those things being in sync then you have a lot more options. mysqldiff.org is a php script that can compare real databases or dump- files. Free. Works but is no longer maintained. I also read about something called SQLSync a few weeks ago. I haven't used it yet but it might be good. http://silvercoders.com/index.php?page=sqlsync In addition to that you can in some cases use this script I found to help with collation and charset changes. http://bogdan.org.ua/2008/02/08/convert-mysql-database-from-one-encodingcollation-into-another.html /Martin On Oct 30, 1:21 pm, Abhimanyu Grover [EMAIL PROTECTED] wrote: I'm sorry this is not Cake related, but I feel its something which most of developers are missing. I found info about Cake migrations and think it would be too difficult to implement it in my team in short time. What tools or techniques are you using to overcome this problem? I'm aware of a tool called SqlYog or something, which is capable of keeping database structured sync'ed from dev. machine to server, but its paid, and I'm looking for some open source alternative, maybe a simple PHP script or something. Please let me know what do you guys use and recommend for a small team? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Looking for suggestion to filter data in cakephp
First I'll admit I did not read through all your code. But I think I get what you are doing. I created a filtering system about a year ago. I wanted/needed something that worked a bit like the find feature in Mac OS X Finder, or in some SQL-GUIs I have used. If you have see this you know what I am talking about. I also needed these to be saved and recalled later. Anyway. I ended up with something that is a lot more streamlined in the controller but with a bit more work done in the Models. Filter is the whole search setup for a particular search. Rule is a single filtering rule. Filter hasMany Rule One Rule can have: - a property to filter - an operator - a value entered by the user End result might be email ends with gmail.com for a single rule. Adding more rules to a Filter would narrow the search using AND. This turned out the be very flexible. A filter can be attached to any other model and do filtering on it. The rule model contained a big data array with different operators (sql fragments) for different types of data. Since humans want to filter numbers differently from email addresses I created a number of these preset custom fragments that could be selected from drop-downs in the gui. The rule model also contained a method for converting the stored parameters (field, match, value) to an sql fragment for a given model. Some examples of fragments: $this-types['Text']['equals'] = '%s LIKE \'%s\''; $this-types['Text']['contains'] = '%s LIKE \'%%%s%%\''; $this-types['Text']['starts_with'] = '%s LIKE \'%s%%\''; $this-types['Text']['ends_with'] = '%s LIKE \'%%%s\''; $this-types['Date']['days_ago'] = 'FLOOR(DATEDIFF(CURDATE(), DATE(%s))) = \'%s\''; $this-types['Date']['weeks_ago'] = 'FLOOR(DATEDIFF(CURDATE(), DATE(%s))/7) = \'%s\''; Each field is mapped to a type. Datetime fields becomes the Date type. Text fields could be set to email or anything but defaults to Text. The filter code was nothing special. The only special method there was getFilterFor($model_name) which gathers the results from each rule. The reason for this setup was partly flexibility and partly the GUI. I really wanted a humane gui. No wildcards or pseudo-sql. Simple selects and meaningful words. Looking back it is not a very difficult setup but it did take some time to come up with the right way to set it all up. I hope that gives you some ideas. Let me know if you want a few more boring details of the implementation. /Martin On Oct 30, 3:43 pm, mario [EMAIL PROTECTED] wrote: Hello everyone, I'm planning to include filters in my new project wherein it will allow the user to filter or show only the information that he/she wants. Of course there would be a search form (textfield,combobox,checkbox, submit button) for this relative to my tables' fieldnames in the database. I've already done this before on my recent project using cakephp. I will post some of my code snippets here for you to make some suggestion and for me to find out if what I'm doing is correct or not. I'm also looking forward on recommendations on how to improve my filtering process (which I'm gonna use on my next project). Here is the code snippet of my controller (I've placed the filters in my index view): --- -- function index($title = null, $location = null, $date_from = null, $date_to = null) { if (empty($this-data) (!$title || ($title == 'allTitle')) (!$location || $location == 'allLocation') (!$date_from || !$date_to)) { $this-paginate['Exhibit'] = array( 'limit' = 1, 'page' = 1, 'order' = array ('Exhibit.title' = 'asc') ); $this-set('exhibits', $this-paginate()); $this-set('reportTitle',null); $this-set('reportLocation',null); $this-set('reportDateFrom',null); $this-set('reportDateTo',null); } else { if(!$title || $title == 'allTitle') { $title = $this-data['Search']['title']; } else { $this-data['Search']['title'] = $title; } if(!$location || $location == 'allLocation') { $location = $this-data['Search']['location']; } else
Re: HABTM in rc3 need now field id in link table.
I think we may be getting a bit off track. Are we discussing schools of though on db design CakePHP requirements of application development? For the table articles_tags the unique identifier is the combination of the two ids. Adding a third field called id and use that as another unique identifier is of-course not a big problem. It is just that it is suddenly required without prior notice and no real explanation as to why. I honestly would like to read about the reasons for the change since I am not sure that it is a new intended requirement. Like I said before, without some official notice of desired change in behavior or requirements, any problem is seen as a bug. All your examples of why a separate pk is needed are uses for you in your application, not internal to Cake for managing the association. Or am I wrong? I have actually not tried looking at Cake's sql output for a join table with an id column. Does Cake write completely different queries if it is there? Mine always specifies the two foreign keys, for example when deleting links. If you use your join tables in reporting then I understand your need for an id (and created and modified). But that is different from something something that was always required for the join table to work correctly. I think it is a very good thing that Cake can now support extra fields in join tables. That was definitely missed in earlier releases. And if an extra id in every join table is the price we pay then that's a small price. On Oct 30, 4:30 pm, teknoid [EMAIL PROTECTED] wrote: Doesn't even matter so much in terms of cake. It's a simple DB design issue. Each record must (should really) have a unique identifier. Considering cake doesn't support compound (or composite) keys it makes the 'id' (primary key column) necessary. First example that popped into my head is a reporting Model that needs to get all associations and report on when a relation between a given User (which HABTMs) Group was created. How else to retrieve the records? What about deleting records? ... and you say that join table may not be accessed directly as a Model. IMO, that happens a lot more often than not. In basic scenarios you may get away with two foreign key fields, hence my original statement: a primary key column should be created in a vast majority of cases. Also, while you can certainly designate a compound key on the DB- level, it has no affect on your cake app, since cake knows nothing about them. Now, all that being said... is there any downside to adding an 'id' column? On Oct 30, 4:58 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Sorry to answer a question with a question... What query would Cake ever need to do to that table where it needed to pick out a single row without knowing the two ids (e.g. article_id, tag_id)? I am of-course talking ab out a clean join table. Not one with extra fields in it. If you make a unique index (or a composite primary key) of the two id fields you prevent duplicate rows and that is all that is needed for that table. If, on the other hand, the table has extra fields (something Cake has previously not supported) and used as a real model, then I certainly see the need for a pk. btw: a composite pk has in my experience never caused any problems. I have used that since before 1.0 went stable. On Oct 29, 8:51 pm, teknoid [EMAIL PROTECTED] wrote: How else would ensure uniqueness of records if cake does not/will not support composite keys? On Oct 29, 3:42 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I don't really agree with the should part. For a standard join table I see no reason for an extra id, and I have not noticed of heard of such a requirement before. Also, when a decision is taken to start requiring a single-field pk in join-tables I would have expected a bit more of a heads-up about it. Any new feature that changes the behavior (not halting on an error but just silently acting differently) of old code will naturally be thought of as a bug by users if there is no clear indication about the changed behavior. About the tests: they are usually the place people get directed to to find out the true implementation of any feature. It is also the standard reply to any bug-report (That the tests pass). So I would not expect them to be out of date in that way. But it is of-course possible. If anyone has link to a document on the change in requirement, I would be grateful. It could be a good read. /Martin On Oct 29, 6:34 pm, teknoid [EMAIL PROTECTED] wrote: Even if those test pass (due to their nature), a primary key column should be created in a vast majority of cases. p.s. It could also be that the tests need to be updated. On Oct 29, 4:34 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Teknoid, you may be right but the fixtures for the tests in the core
Re: HABTM in rc3 need now field id in link table.
Teknoid, you may be right but the fixtures for the tests in the core create loin tables without a pk. E.g: var $fields = array( 'article_id' = array('type' = 'integer', 'null' = false), 'tag_id' = array('type' = 'integer', 'null' = false), 'indexes' = array('UNIQUE_TAG' = array('column'= array('article_id', 'tag_id'), 'unique'=1)) ); /Martin On Oct 28, 3:56 pm, Alexandru [EMAIL PROTECTED] wrote: no no in rc2 this was on manual Recipe HABTM Tag = recipes_tags.recipe_id, recipes_tags.tag_id BUT now they changed in manual and put this Recipe HABTM Tag = id,recipes_tags.recipe_id, recipes_tags.tag_id now i know for sure it is NOT a BUG. TOPIC CLOSED --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Problem on Error Handling with CAKEPHP
Hi I would use the Error HAndling of CAKEPHP. I create a my function in app_error.php Now if I set the debug to 0 if I use this function I get always another page (I think the error404 ) If I set debug to 1 I get the right error's page but I get a performance's worsening. What can I do ? Many 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---