Determine to insert or update data in beforeValidate().
In cake 1.2, I have some logic in beforeValidate() to determine the data going to be saved should be inserted (new record), or updated (by setting $model->id within beforeValidate()). Everything works fine. Now I am migrating to cake 1.3, but it doesn't work anymore. If I don't set $model->id to a valid record ID before calling $model- >save(), then it is always an insert. I could imagine it is a common problem, but probably I am missing something, i.e. if beforeValidate() shouldn't be the place to decide an insert/update, what is the cake way to do it? Any input? Appreciate. --Lapinski Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Select Distinct only for Unique fields?
What do you mean by "it doesn't work"...? any more details? --Lapinski gimperdaniel wrote: > > > I am having a problem with SELECT DISTINCT > > This is what I have in my model: > > This works: > > $this->find('all', array('fields'=>array('DISTINCT Album.id', > 'Album.year'), 'recursive'=>-1)); > > This Doesn't Work: > > $this->find('all', array('fields'=>array('DISTINCT Album.year'), > 'recursive'=>-1)); > > > Album_id is a unique (index) field. Is that why it works on the first > one and not on the second one? > > > > -- View this message in context: http://www.nabble.com/Select-Distinct-only-for-Unique-fields--tp26100117p26103511.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Manipulating data fields with different array structure in model callback methods
I am trying to look for a generic way to manipulate model data, say, in beforeValidate in model. The model data could be in different array structure (or shape). For example, the field to be validated can be in the following 5 cases (and possibly more): array['ModelName'][0]['field'] array[0]['ModelName'][field'] array['ModelName']['field'] array['ParentModelName']['ModelName']['field'] array['ParentModelName'][0]['ModelName']['field'] Is there a generic "cake" way to handle this, or I have to make a if-else condition to go through all the possible scenarios case by case? Thanks! --Lapinski -- View this message in context: http://www.nabble.com/Manipulating-data-fields-with-different-array-structure-in-model-callback-methods-tp26078723p26078723.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Validating data from single or multiple records.
I am trying to look for a generic way to validate model data that could be in different array structure (or shape). For example, the field to be validated can be in the following 5 cases (and possibly more): array['ModelName'][0]['field'] array[0]['ModelName'][field'] array['ModelName']['field'] array['ParentModelName']['ModelName']['field'] array['ParentModelName'][0]['ModelName']['field'] Is there a generic way to handle this, or I have to make a if-else condition to go through all the possible scenarios case by case? Thanks! --Lapinski -- View this message in context: http://www.nabble.com/Validating-data-from-single-or-multiple-records.-tp26078569p26078569.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: need some help with routes...
* matches everything (including /), so your syntax will not only match what you wanted, but also match some URLs that you may not want (e.g. '/artist/ARTISTNAME/this_is_not_album_name/album/ALBUMNAME'). Lapinski gimperdaniel wrote: > > > Ok, this is what I have now.. and it works.. can someone just tell me > if it's the right way to do it? > > Router::connect('/artist/*/album/*', array('controller' => 'albums', > 'action' => 'view')); > > On Oct 15, 6:20 pm, "gimperdan...@gmail.com" > wrote: >> I am learning about routes now, I used to write my own routes on mod >> rewrites before i came to Cake, so I just need some small guidance >> since I already have some knowledge... >> >> Here's what I need to accomplish: >> >> www.myswebsite.com/artist/ARTISTNAME/album/ALBUMNAME >> >> On mod rewrite I just had to sub ARTISTNAME & ALBUNAME for two >> variables and get the values through GET... I just need to accomplish >> the same using the Router. >> >> Both ARTISTNAME and ALBUMNAME are UNIQUE fields in two separate tables. > > > > -- View this message in context: http://www.nabble.com/need-some-help-with-routes...-tp25916976p25932669.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to make this query the Cake way?
You will need to force an SQL JOIN by rebinding Robot HABTM Tag to Tag belongsTo Robot, then use $this->Robot->Tag->find(...) with recursive = 2 (or you may use Containable behavior) to construct your desired SQL statements. If you have to do it through $this->Robot->find(...) you'll need to rebind Robot hasOne Tag which I am not sure if it will get everything you want. See this post by teknoid for more details: http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ Lapinski Xoubaman wrote: > > > Robot HABTM Tag > User hasMany Robot > Robot belongsTo User > > I want to get related robots based on his tags. More tags in common, > more related. > > So, whats the way to put this query using $this->Robot->find(...) or > $this->Robot->RobotsTag->find(...) > > SELECT count(tag_id) as total, Robots.*, Users.username > FROM > (`robots_tags` INNER JOIN robots ON (robots_tags.robot_id = > robots.id)) > INNER JOIN users ON robots.user_id=users.id > WHERE tag_id IN (1,2,3) > GROUP BY robot_id > ORDER BY total DESC > LIMIT 4 > > > > -- View this message in context: http://www.nabble.com/How-to-make-this-query-the-Cake-way--tp25878312p25884721.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Paginate - order clause is ambiguous!
Try this: var $paginate = array ('order' => 'Page.index'); Lapinski mig_akira wrote: > > Hello everyone! > > I'm having a problem here. > > I have a table Pages, which belongsTo Categories. I'm using an "ordenable" > behaviour, and so both pages and categories have a field called "index". > Problem is, in my pages_controller, i wrote this: > > var $paginate = array ('order' => 'index'); > > And as a result, I receive an error saying > > SQL Error: 1052: Column 'index' in order clause is ambiguous > > It must be because both categories and pages have the same field. I cant > change this field...so how can I specify that I want to use the index from > the Pages table? > > Thanks!! > -- View this message in context: http://www.nabble.com/Paginate---order-clause-is-ambiguous%21-tp25530985p25530991.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to reach a url from form inputs without using ajax
If I understand you correctly, you would want to use the routing feature in Cake. Under config/routes.php, add a reroute rule so that link/edit/id points to edit(id) action in Link controller. Lapinski Airzebeth wrote: > > > Hello everybody, > > I'm new with cakePHP and I have some difficulties understanding the > constrains of url format. > Sorry in advance if my question is stupid or has been already asked > but I couldn't find any matching subject. > > Here's my problem. > Let's say I have a Link class which stocks my bookmarks. > Let's say on my homepage I have a form that allows me to choose a Link > from a select box and then send me to the edit page of that link. > With regular php, that would give something like that : > > > Link1 > Link2 > Link3 > > > > > I would like to know how I am supposed to do this with Cake. Of course > I know how to build a form such as the one above with cake but I can't > figure out how to translate the information passed so cake > automatically understands it has to redirect me to link/edit/id > without doing a redirect in the Link controller. > In other words, I would like to know id there is another way to call > pages than with complete urls, for example, like here, width post > data, like in regular php where the example below equals : > link_edit.php?id=1 (if I choose the first item of the select). > > I hope I made all this clear, maybe my question doesn't make any sense > in Cake, maybe my mind is just not baked enough :) > Thank you in advance for your answer and sorry for my English. > > > > > -- View this message in context: http://www.nabble.com/How-to-reach-a-url-from-form-inputs-without-using-ajax-tp25393722p25394253.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: i am facing problem in Localization in CakePHP
What exactly isn't working for you? anurag-16 wrote: > > > In recent Cakephp version (1.2x) i am try to implement multilanguage > app on cakephp by using guidelines of Cookbook online manual. > > http://book.cakephp.org/view/163/Localization-in-CakePHP > > But its not working... > > Please help me out. > > > > > -- View this message in context: http://www.nabble.com/i-am-facing-problem-in-Localization-in-CakePHP-tp24845727p24857822.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Model Find With Conditions On Associated Models Not Working
http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ http://teknoid.wordpress.com/2008/09/05/example-of-cakephps-containable-for-deep-model-bindings/ Lapinski erturne wrote: > > > On Dec 7, 5:48 pm, brian wrote: >> I misinterpreted MenuPostings. I thought it was a table of comments or >> something like that. So, it seems that, though there may be many >> MenuPostings for a particularMenu, only a single one is really >> "active" at a given time. Is that the case? If so, why not just add >> columns post_start & post_end to the menus table and modify them >> whenever the posting dates for a menu need to be changed? That would >> make your query much simpler. >> > > They want to set up their menu schedule ahead of time, and not have to > remember to set the next posting each time one expires. I can also > envision other situations like this in other applications, and as this > is my first Cake app I'd like to learn what the limitations of the > technology are. In this case I COULD attack the problem from a > different angle, starting with MenuPosting rather than Menu so that I > can specify conditions on the post_start and post_end, but I don't > like the idea changing simply because I don't understand how to make > it work the way I want to. I'd really like to find out if it's > possible to do what I want (obtain menus filtered based on the > criteria of an associated model). Or if it's not possible, why. > >> On Sun, Dec 7, 2008 at 5:27 PM, erturne >> wrote: >> >> > On Dec 7, 1:54 pm, brian wrote: >> >> You need a LEFT JOIN in your query. MenuPosting can't be in the WHERE >> >> clause. Perhaps if you post the actual SQL query you're aiming for we >> >> can figure out how to have Cake generate it. >> >> > Essentially I want information about menus and the entrees on them. >> > Something like: >> >> > SELECT Menus.title, Entrees.name FROM menus Menus >> > INNER JOIN entrees_menus EntreesMenus ON EntreesMenus.menu_id=Menus.id >> > INNER JOIN entrees Entrees ON EntreesMenus.entree_id=Entrees.id >> > INNER JOIN menu_postings MenuPostings ON MenuPostings.menu_id=Menus.id >> > WHERE MenuPostings.post_start <= NOW() AND MenuPostings.post_end > NOW >> > (); >> >> > Of course I'll eventually want more than just the menu title and >> > entree names, but that's good enough for now. >> >> > I don't think LEFT JOIN is correct for what I need because I'm not >> > interested in a menu without entrees! INNER JOIN is the way to go >> > here. Not sure if we can make CakePHP do that using find() or >> > Containable or unbindModel()/bindModel(). I'm definitely open to >> > suggestions. >> >> >> What are post_start & post_end, anyway? >> >> > Records in the menu_postings table define when each menu is visible on >> > the website. We might have a particular menu visible on the website at >> > various times throughout the year (defined by post_start and >> > post_end). >> >> >> On Sat, Dec 6, 2008 at 10:06 PM, erturne >> wrote: >> >> >> > I've seen similar questions raised but haven't found a solution that >> >> > works. Perhaps it's because I'm new to CakePHP and don't fully >> >> > understand unbindModel(), bindModel(), container behaviors, etc. >> >> > Anyway, I'll start simple and take suggestions. >> >> >> > I have the following models in which a Menu hasAndBelongsToMany >> Entree >> >> > and hasMany MenuPosting, and a MenuPosting belongsTo Menu: >> >> >> > class Menu extends AppModel { >> >> > var $name = 'Menu'; >> >> > var $hasAndBelongsToMany = 'Entree'; >> >> > var $hasMany = array( >> >> > 'MenuPosting' => array( 'dependent' => true ) >> >> > ); >> >> > } >> >> >> > class MenuPosting extends AppModel { >> >> > var $name = 'MenuPosting'; >> >> > var $belongsTo = 'Menu'; >> >> > } >> >> >> > class Entree extends AppModel { >> >> > var $name = 'Entree'; >> >> > } >> >> >> > In my MenusController I have a display_current() action to find all >> >> > menus that are currently
Re: Model Association via "conditions" fails!
http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ Lapinski ohneworte-2 wrote: > > > Hello Together, > I want to link two Models without using a Foreign Key, but using some > Conditions instead. Here is my example: > > Model: > - > class Category extends AppModel { > var $name = "Category"; > var $actsAs = array("Containable"); > > var $hasMany = array( > "Zone" => array( > "foreignKey" => false, > "conditions" => array( > "AND" => array("Category.width = Zone.width", > "Category.height = > Zone.height") > ) > ) > ); > } > > Controller: > -- > $category = $this->Category->find("first", array( > "conditions" => array("Category.id" => 1), > "contain" => array( > "Zone" > ) > )); > > Result: > -- >>>SQL Error: 1054: Unknown column 'Category.width' in 'where clause'<< > > That seems clear if you make a look on the generated Query: >>>SELECT ... FROM 'zones' AS 'Zone' WHERE (('Category'.'width' = 'Zone'.'width') AND ('Category'.'height' = 'Zone'.'height')) << > > No Join occurs - but why? Can anybody help me out? > I appreciate any help on this issue. > > Regards. > > > > -- View this message in context: http://www.nabble.com/Model-Association-via-%22conditions%22-fails%21-tp23213390p24621578.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: 404 Header
Did you turn debug mode off? Ma'moon Al-Akash wrote: > > Sure ... > HTTP/1.1 302 Found > Date: Tue, 21 Jul 2009 20:00:04 GMT > Server: Apache > X-Powered-By: PHP/5.2.6 > Location: http://video.maktoob.com/?url=sfgsd > Cache-Control: private, no-cache, no-store, proxy-revalidate, > no-transform, > max-age=0, must-revalidate > Expires: Tue, 21 Jul 2009 20:00:04 GMT > Vary: Accept-Encoding,User-Agent > Content-Type: text/html > Connection: Keep-Alive > Set-Cookie: userCountry=JO; expires=Thu, 17-Dec-2020 19:00:04 GMT; path=/ > Set-Cookie: MKTID_copy=deleted; expires=Mon, 21-Jul-2008 20:00:03 GMT; > path=/; domain=video.maktoob.com > > On Tue, Jul 21, 2009 at 6:18 PM, Piotr Kilczuk wrote: > >> >> Hello, >> >> > i have a problem with my CakePHP app where the client needs me to >> return >> a >> > valid 404 page together with a valid 404 http header incase of "page >> not >> > found", i have handled the 404 page through app_error but the problem >> is >> > when i execute ( curl -I http://www.example.com/sdfsdfas ) on my debian >> box >> > it keeps returning ( 302 Page Found ) instead of ( 404 Page Not Found) >> , >> > anyone faced something like this, and if any, would you please explain >> how >> > you solve it? >> >> Can you paste the complete response (all server headers)? >> >> >> Regards, >> Piotr >> >> > >> > > > -- > http://phpirate.net > > > > > -- View this message in context: http://www.nabble.com/404-Header-tp24587977p24612078.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to keep Session data clean and not messed up
Why it doesn't work for you? If you need everything fresh every time a user starts over, then POST is a solution. Lapinski Raph-8 wrote: > > > Yes - I'm afraid you missed the point. ;) > > It's only an example and using $_POST it's not the solution IMHO. > > On 19 Lip, 15:50, MrMeikel wrote: >> (Apologies if I have missed the point...) >> >> If you only want to save information when the user has gone from pageA >> directly to pageB, couldn't you use $_POST? Sounds like you're using a >> form anyway, so just set the target to pageB and check the (correct) >> information has been passed - ie. posted from pageA. >> >> On Jul 19, 1:43 pm, Raph wrote: >> >> >> >> > Let's say I've got an exmaple application, and in this application >> > there are a few wizards. User goes to one of the wizards, inputs data >> > in form in step 1, then goes to step 2. Data from step 1 was saved in >> > session. Now user should do somehting in step 2 and go to step 3, but >> > he dosen't do that. He clicks "back" button in his browser, or maybe >> > he types url in address bar and goes to place in the system outside >> > the wizard. >> >> > The problem is those data in session. It wasn't removed and it still >> > there. User could go to another wizard and do the same thing and new >> > unnecessary data appear in session. >> >> > How you handle situations like that? >> >> > -- >> > Raph > > > > -- View this message in context: http://www.nabble.com/How-to-keep-Session-data-clean-and-not-messed-up-tp24556669p24560643.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Blank white screen on new upload
Are you sure index.php under webroot/ is pointing to the right ROOT, APP_DIR and CAKE directories? Lapinski Lisa-69 wrote: > > > Hiya, > > Our client has a site built with CakePHP and has today had a prob with > their previous host - so we've quickly had to move it all to a new > hosting account. > > We've got everything uploaded and all paths seem to be ok - but > when .htaccess is set to redirect to app/webroot it just returns a > blank white screen. > We've checked PHP is working (we've tried a lot of stuff!), we've > tried turning Debug to 2 to show errors but it doesn't make any > difference, and we've tested mod rewrite is apparently on. > > Any ideas gratefully received! It's been a very long day and we need > to go to bed! > > Thank you! > > Lx > > > > > -- View this message in context: http://www.nabble.com/Blank-white-screen-on-new-upload-tp24526674p24527093.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Localization - values in translated strings - my solution
Thanks for your suggestion, but is there any way to accomplish this without changing the cake core? Lapinski Julien Buratto-5 wrote: > > > I thought that this could interest someone else. > > If you want to be able to translate strings which contains dynamic > data such: > "Hello, my name is Julien" where "Julien" is a name, you could do > this: > > sprintf(__("Hello, my name is %s",true),"Julien"); > > and your translation string would be "Hello, my name is %s" which is > easy to translate. > The issue with that is that it's absolutely not handy to use in views. > > What I liked to have was a function where I could pass values, such > as: > > __("Hello, my name is %s and I'm %d years old",true,array("Julien", > 34)); > expected result: > Hello, my name is Julien and I'm 34 years old. > > Id order to achive this I have changed the cake/basics.php file where > the __ function is located, basic steps are: > - add a third parameter to the function __ in order to support the > array of values > - use the vsprintf to pass an array of values to the sprintf string > - evaluate if there are any value passed otherwise use the older > behaviour > > Result is very simple and looks clean to me: > > /** > * Returns a translated string if one is found; Otherwise, the > submitted message. > * > * @param string $singular Text to translate > * @param boolean $return Set to true to return translated string, or > false to echo > * @return mixed translated string if $return is false string will be > echoed > * @link http://book.cakephp.org/view/693/__ > */ > function __($singular, $return = false,$values=array()) { > if (!$singular) { > return; > } > if (!class_exists('I18n')) { > App::import('Core', 'i18n'); > } > > if ($return === false) { > if (count($values)>0) echo > vsprintf(I18n::translate($singular), > $values); > else echo I18n::translate($singular); > } else { > if (count($values)>0) return > vsprintf(I18n::translate($singular), > $values); > else return I18n::translate($singular); > } > > > > > > -- View this message in context: http://www.nabble.com/Localization---values-in-translated-strings---my-solution-tp24180760p24183152.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Change the content-type
I can confirm that Miles J was correct. I just added this to my controller: $this->RequestHandler->respondAs("text/xml") but on the client side, responseXML is null (in prototype.js Ajax onSuccess callback). But if I added this to my controller as Miles J suggested: $this->header('Content-Type: text/xml'); I got an XML object in my responseXML. Are we missing something? Or the requesthandler is not working as wished? Lapinski jperras wrote: > > > Use the RequestHandlerComponent::respondAs method. This should set the > appropriate content-type headers based on the $type that you give it. > > http://api.cakephp.org/class/request-handler-component#method-RequestHandlerComponentrespondAs > > -j. > > On Jun 15, 4:15 pm, Miles J wrote: >> But it doesn't work. Even if you use the Request Handler to output as >> XML, it is not XML. >> >> On Jun 15, 7:50 am, jperras wrote: >> >> > You should be using the RequestHandler Component for content-type >> > setting/detection of your views and actions. >> >> >http://api.cakephp.org/class/request-handler-component >> >> > -j. >> >> > On Jun 14, 5:56 pm, Peter wrote: >> >> > > thanks, that's what i neededalthough i moved it to the top of the >> > > default xml-layoutfile i use. >> >> > > On 14 jun, 23:44, Miles J wrote: >> >> > > > I usually put this at the end of my controller actions: >> >> > > > $this->header('Content-Type: text/xml'); >> >> > > > On Jun 14, 10:26 am, Peter wrote: >> >> > > > > how can i change the content-type of a view? i have an xml-view >> which >> > > > > renders just fine, but my browser sees it as text/html. > > > > -- View this message in context: http://www.nabble.com/Change-the-content-type-tp24024660p24105688.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: xml not parse correctly
my_xml_file.xml is not a valid xml file. a valid xml file needs to have a root node. so if you modify the file to include a root node (such as ...) then the parsing should work. Lapinski robert123 wrote: > > > i am using the below codes, took from the bakery, straight > > App::import('Xml'); > > // your XML file's location > $file = "my_xml_file.xml"; > > // now parse it > $parsed_xml =& new XML($file); > $parsed_xml = Set::reverse($parsed_xml); // this is what i call > magic > > // see the returned array >var_dump($parsed_xml); > it shows > array(1) { ["Order"]=> array(1) { ["id"]=> string(7) "3525314" } } > > the my_xml_file.xml have the data below > > > > it has two order data, the my_xml_file.xml was generated from the > database using $xml->serialize($data); > > but whenever the code above is executed I only get > Array ( [Order] => Array ( [id] => 3525314 ) ) > > that is it is only reads the first order and never the second order, > how can i make it to read the whole xml data into an array, thank you > > > > > http://www.generics.ws > > > > -- View this message in context: http://www.nabble.com/xml-not-parse-correctly-tp24008520p24015474.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Session.timeout vs session cookie expiration date
I was having the same concern. I looked at session.php (under cake/libs/), in function __initSession(): security: high : $this->cookieLifeTime = 0 security: medium : $this->cookieLifeTime = 7 * 86400 security: low : $this->cookieLifeTime = 78894 foldiman wrote: > > > I haven't found any documentation on this. But I'm assuming the > Session.timeout and Cookie expiration date are not equal. In fact, by > experimenting with the three different security levels, I found the > following: > > low = cookie expires in 25 years > medium = cookie expires in 1 week > high = cookie expires at the end of the session > > Can anyone confirm these values? Also, I'm assuming a new session uses > the same cookie if it exists rather than overwriting itcorrect? > > Thanks. > > > > -- View this message in context: http://www.nabble.com/Session.timeout-vs-session-cookie-expiration-date-tp23985613p23987281.html Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Telling PHP to put "&" NOT "&"
Did you encodeURI() your data before you send it by javascript? I never used jQuery, but I will be surprised if jQuery don't have a function to wrap everything from your form, encodeURI() them before sending it to your server. You shouldn't be seeing your data truncated, as & should have been encoded as %26 already. On May 3, 12:51 pm, rartavia wrote: > Hello guys, thanks for your answers. > > As I supposed, it was the debugger::log() function the one converting > '&' into amp, the real problem was in Dr. Loboto's (thanks man) > observation about the reference parameter. After correcting it, I got > in my DB "&#NUMBER;" no need for more, here is the correction: > > function restore_html_ecoded_characters(&$pArray){ > foreach($pArray as $key => $value){ > if(is_array($value)){ > restore_html_ecoded_characters($pArray[$key]); > }else{ > $pArray[$key] = str_replace("_#", "&#", $value); > } > } > > } > > Lapinski: About your suggestion, I like it for entities as áéíóú but > what about the ampersand? I'm sending via ajax something like this: > jQuery.ajax({ > data:"data[Model][attribute]=value1&data[Model][attribute2]=value2&data > [Model][attribute]=value3&...", > ...otherAjaxOptions...}); > > some of my values contain '&' which would, for cake divide the > parameter value, > IE: "data[Model][url]=http://somepage.com/ > example&hl=en&fs=1">...&..." > in controller, when I read data["Model"]["url"] would be > "http://somepage.com/example"; ignoring the rest since > the ampersand is the parameter separator. For the rest, for sure i'll > use php's htmlentities, that way is less processing in JavaScript, > thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Telling PHP to put "&" NOT "&"
Did you encodeURI() your data before you send it by javascript? I never used jQuery, but I will be surprised if jQuery don't have a function to wrap everything from your form, encodeURI() them before sending it to your server. You shouldn't be seeing your data truncated, as & should have been encoded as %26 already. On May 3, 12:51 pm, rartavia wrote: > Hello guys, thanks for your answers. > > As I supposed, it was the debugger::log() function the one converting > '&' into amp, the real problem was in Dr. Loboto's (thanks man) > observation about the reference parameter. After correcting it, I got > in my DB "&#NUMBER;" no need for more, here is the correction: > > function restore_html_ecoded_characters(&$pArray){ > foreach($pArray as $key => $value){ > if(is_array($value)){ > restore_html_ecoded_characters($pArray[$key]); > }else{ > $pArray[$key] = str_replace("_#", "&#", $value); > } > } > > } > > Lapinski: About your suggestion, I like it for entities as áéíóú but > what about the ampersand? I'm sending via ajax something like this: > jQuery.ajax({ > data:"data[Model][attribute]=value1&data[Model][attribute2]=value2&data > [Model][attribute]=value3&...", > ...otherAjaxOptions...}); > > some of my values contain '&' which would, for cake divide the > parameter value, > IE: "data[Model][url]=http://somepage.com/ > example&hl=en&fs=1">...&..." > in controller, when I read data["Model"]["url"] would be > "http://somepage.com/example"; ignoring the rest since > the ampersand is the parameter separator. For the rest, for sure i'll > use php's htmlentities, that way is less processing in JavaScript, > thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Telling PHP to put "&" NOT "&"
Did you encodeURI() your data before you send it by javascript? I never used jQuery, but I will be surprised if jQuery don't have a function to wrap everything from your form, encodeURI() them before sending it to your server. You shouldn't be seeing your data truncated, as & should have been encoded as %26 already. On May 3, 12:51 pm, rartavia wrote: > Hello guys, thanks for your answers. > > As I supposed, it was the debugger::log() function the one converting > '&' into amp, the real problem was in Dr. Loboto's (thanks man) > observation about the reference parameter. After correcting it, I got > in my DB "&#NUMBER;" no need for more, here is the correction: > > function restore_html_ecoded_characters(&$pArray){ > foreach($pArray as $key => $value){ > if(is_array($value)){ > restore_html_ecoded_characters($pArray[$key]); > }else{ > $pArray[$key] = str_replace("_#", "&#", $value); > } > } > > } > > Lapinski: About your suggestion, I like it for entities as áéíóú but > what about the ampersand? I'm sending via ajax something like this: > jQuery.ajax({ > data:"data[Model][attribute]=value1&data[Model][attribute2]=value2&data > [Model][attribute]=value3&...", > ...otherAjaxOptions...}); > > some of my values contain '&' which would, for cake divide the > parameter value, > IE: "data[Model][url]=http://somepage.com/ > example&hl=en&fs=1">...&..." > in controller, when I read data["Model"]["url"] would be > "http://somepage.com/example"; ignoring the rest since > the ampersand is the parameter separator. For the rest, for sure i'll > use php's htmlentities, that way is less processing in JavaScript, > thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Telling PHP to put "&" NOT "&"
Why did you need to hack it this way? Why not just leave the user input intact and convert them to html entities by php? http://us3.php.net/htmlentities On May 2, 6:13 pm, rartavia wrote: > Hi there. > > Benedikt: I did try str_replace, preg_replace and strtr, same result. > > Lapinski: What I'm doing is with JavaScript replacing some characters > (á,é,í,ó,ú,&) to there html character (ie -> á: á) but if I sent > to server data[Model][value]=á would fail since the ampersand is > the parameter separator so when I read in my controller data['Model'] > ['value'] it would be blank, my solution for that was using _#225; > instead of á and then my idea is to replace it in the server for > the ampersand and then save to DB. > > Despite everything, there are two details, one; that I i'm seeing the > & in the log (debugger::log($value)) so it may be the log() the > one converting it (sorry if this is known, i didn't know, and its only > a supposition of mine) and also, if you see my code I'm using a > reference parameter (&pArray) so that my original array gets modified > there, and then I saveAll($modified_array). But when I look at the > database, the value is saved as if it was never modified, as _# > instead of &# or even &. So I think the real problem is else > where. > > thanks for your answers, I appreciate any help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Search engine like function?
check out http://bakery.cakephp.org/articles/view/sphinx-behavior and see if it fits your need? On May 1, 9:00 am, mbourque wrote: > I am building a data warehouse site that contains a lot of customer info. I > need to allow users of my app to have a search page that lets them enter > natural search strings to find and narrow search results. > > I wanted each word on the search field to be treated as AND clause in my > search. I also need the search to act like full text where multiple fields > are considered for a match. I also have a special case whereas a numeric > keyword is treated special and only certain fields are searched in that > case. > > Examples: > > Keyword: dave > Searches: ( `User`.`name` like '%dave%' OR `User`.`email` like '%dave%' ) > > Keyword: dave thomas > Searches: ( ( `User`.`name` like '%dave%' OR `User`.`email` like '%dave%' ) > AND ( `name` like '% thomas%' OR `email` like '% thomas%' ) ) > > Keyword: 341 > Searches: ( `User`.`id` = '341' ) > > I have written a model function that divides the keywords into an array and > creates an array of conditions that I pass to the find() command. This works > great. > > However this feels like a very common pattern, and I wonder if I just > reinvented the wheel? Sooner or later I will be asked to add special keyword > handlers such as: > > dave OR thomas > dave AND thomas > "dave thomas" > "dave thomas" OR "david thomas" > > Is there already a cake pattern or helper that exists that I should be > using? If not I may just create one for the good of the community. > -- > View this message in > context:http://n2.nabble.com/Search-engine-like-function--tp2753945p2753945.html > Sent from the CakePHP mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Telling PHP to put "&" NOT "&"
did you try to debug your output right after the replacement? it looks to me that you're reading the XHTML output from the browser... On May 2, 12:29 am, rartavia wrote: > Hello, i'm trying to make a replace of a character in a string for an > '&'. I tried several ways of replacement but (cake)PHP, when I do > str_replace("_", "&") it returns "&"(HTML encoded). How can I get > the replacement to be an ampersand itself? > > My code: > /** > * From client comes all special characters encoded > * HTML encoded but instead of NUMBER; => _#NUMBER; > * This Method restores to NUMBER; > **/ > function restoreHTMLEcodedCharacters(&$pArray){ > foreach($pArray as $key => $value){ > if(is_array($value)){ > restoreHTMLEcodedCharacters($value); > }else{ > //debugger::log($value); > $value = preg_replace("_#", "", $value); > $value = str_replace("&", "&", $value); > } > } > > } > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---