Re: PHP Code in Database
A safer alternative to eval() would be to store in the database the object name, the method and the arguments, so you can use call_user_func(). I highly recommend you to whitelists the allowed calls (that is, make a list of possible objects and methods that can be called). I had a similar need once, but I stored code in XML. If you allow users to input code that will be run, you're allowing them to mysql_query('DROP DATABASE BLABLA'); to say the least. Take care! dfcp On Friday, August 10, 2012 5:20:36 AM UTC-3, Sanjeev Divekar wrote: Hello, I am developing CMS which need to execute some php code e.g. ?php echo $this-element('helpbox'); ? which is stored in database. I tried file_put_contents ('tempfile.tmp',$this-fetch('content')); include('tempfile.tmp'); in layout which works but any better Idea? Regards, -- 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. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Re: Custom model association column
Hello all, Your suggestions would work, however I`m trying to get a shortcut here = eliminating the Subject. is there any way that we could specify a join condition, like 'hasMany' = array( 'model' = 'Contents', 'join' = 'Contents.subject_id = HospitalAdmission.subject_id' ... ) ? On Feb 22, 6:16 am, Stephen Speakman step...@ninjacodermonkey.co.uk wrote: Something i need to bear in mind when mapping my models, no joining between two connections. Could you not find a behaviour to create a temporary table as a very last resort? Sent from my iPhone On 21 Feb 2012, at 21:37, jeremyharris funeralm...@gmail.com wrote: Does Containable not work? $this-HospitalAdmission-find('all', array( 'contain' = array( 'Subject' = array( 'Contents' ) ) )); -- Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Am I Violating MVC?
What does '3' mean? Let's go and look in the code - oops, I don't know how to. not only this. Suppose you need to add the #4 record - or maybe change something on the #3. the array datasource is, IMO, the right answer for this problem. It allows to keep the data where it belongs, in the M of MVC. however, as jeremy pointed out, if your data is going to live outside cakephp, problems arise. Sometimes, for this kind of problem, I use varchar keys, so instead of having autoincremental ids, I have readable things. InnoDB is ok with that, and performance in a 500Mb database is good. Don't mentioning the code - it's SO much better to write $data = $this-Model-find('all', array( 'conditions' = array( 'type_id' = 'unconfirmed' ) ) ); than 'type_id' = 1. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Am I Violating MVC?
I think it depends whether you store this value in the database or not. If you do, the right thing is to create a table and then accessing it by a model. For a very good reason, in big projects you don't want to lose time thinking is it a table or a array within a controller? in which controller is it?. Also, if this value is used in the database, later you may want to write a single query to retrieve this data, and run this query on the console (or a backup script, e.g.) and suddenly you realized that that tied you to cakephp. If you think that's the best solution (to keep this data as an array), the ideal solution (in my mind) would be to have a Model which access this array instead of a database table. If you only need it for drop boxes, maybe this: app/models/gender.php class Gender // extends nothing { var $data = array( 'M' = 'Male', 'F' = 'Female' ); function find($type,$opt=null) { if ( $type='list' ) return $data; throw new exception( find('$type') in bogus model isn't supported - maybe it's time to use a real table. ); } } I know, it's ugly, but what's the upside of all this coding? All data in accessible by models, and you didn't wrote a lot of database tables that will never change. I would love proper support of virtual models that access data on a CSV, static array, etc. dfcp On 18 maio, 15:46, Jason Mitchell jason.a.mitch...@gmail.com wrote: I have in a controller an array containing data used on the view to populate a drop down. I put it on the controller, so the array could be used by multiple views associated with that controller (create, edit). Additionally, it means that if I do ever have to change it, I just have to change it once (yup, lazy). Because the data is relatively static, and is used in only isolated instances, it didn't seem to be worth the effort of creating a model for that data, and establishing a relationship between models. And, putting it on the controller, worked. Admittedly, I'm new to MVC, but this really doesn't seem to jive definition. Am I doing something wrong? If so, how would one but this on the model, short of some sort of association with another model? -- J. Mitchell -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: conversion of mysql query to cakephp query
Miles, that would require SELECTing the value of balance beforehand. I [1] thought that $model-save( array('id'='1','balance'='-!balance+5') ); would work, but it didn't in my cake1.3.3 [1] http://cakebaker.42dh.com/2007/05/04/how-to-use-sql-functions-in-conditions/ On 26 nov, 23:29, Miles J mileswjohn...@gmail.com wrote: $this-id = 1; $this-save(array('balance' = $balance - 5)); On Nov 26, 12:58 am, Vivi Vivi vivianbog...@gmail.com wrote: http://book.cakephp.org/view/1031/Saving-Your-Data On Fri, Nov 26, 2010 at 10:19 AM, Biplab Subedi bipla...@gmail.com wrote: Help me in converting this mysql query to cakephp query $query=UPDATE tbl_user SET balance=(balance-5) WHERE id='1; Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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.comcake-php%2bunsubscr...@googlegroups.c omFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en -- Vivihttp://photos.vr-3d.net 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: CakePHP high CPU utilization
its hard to say... you might check which processes the CPUs are running. I'm not familiar with sar, but top and ps let you know which are the processes consuming most CPU/memory. if it's httpd, then you're right, cakephp is consuming all those cpu cycles. alas, you may check for invalid redirections - I once had this faulty app that kept on redirecting endlessly to the same page, and it went just like your machine did. i'm running 10 cakephp apps on production level (~30.000 hits/day) since the days of cake 1.1 and, except for the above, never had any problem like yours. dfcp On 23 out, 14:49, airween airw...@gmail.com wrote: Hello Cake Users, I'm new in Cake - exactly I'm not a Cake user/developer, I'm a system administrator. System is a LAMP enviroment, hardware is a HP DL380, with two CPU, every CPU has 2 cores. I've a site since few weeks ago - since then the CPU utilization isn't above 100%, but usually over 200%. I've created a controller, which does nothing: it contains just a simple index() method, which's empty. Also I configured the routes, and when I get the URL: http://mysite/foo the default layout rendered, which has a header and a footer. I tested this controller on an another HW, which has 8 core; the client was ab (apache benchmark), and until the test I've monitored the system: sar -P ALL 1 1000 (client: ab -n 100 -c 100 http://mysite/foo) Until the test sar reported this values: 19.27.17 CPU %user %nice %system %iowait %steal %idle 19.27.18 all 88,38 0,00 10,88 0,00 0,00 0,75 19.27.18 0 89,00 0,00 9,00 0,00 0,00 2,00 19.27.18 1 83,00 0,00 17,00 0,00 0,00 0,00 19.27.18 2 91,00 0,00 9,00 0,00 0,00 0,00 19.27.18 3 90,00 0,00 10,00 0,00 0,00 0,00 19.27.18 4 90,10 0,00 9,90 0,00 0,00 0,00 19.27.18 5 86,87 0,00 13,13 0,00 0,00 0,00 19.27.18 6 91,00 0,00 9,00 0,00 0,00 0,00 19.27.18 7 87,00 0,00 10,00 0,00 0,00 3,00 When test has finished, the %user has gone 0,00, and %idle about 99,9% again. On that machine another MVC frameworks and another sites (CMS's) (which uses Codeigniter, Drupal...) I _can't_ create this effect. I don't use .htaccess. Cake version is 1.2.8, I downloaded it today. What could be the problem? Thank you: a. 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: Countries, States and Cities: Which relations i'm dealing with?
I'd put capital_id fields on tables contry and state. I don't like having a field that is 0 most of the time. Or, if you want to model countries like the netherlands or south africa, that have administrative, legislative and financial (i guess) capitais in different cities , you should have a country_capitals table. Dfcp On 24 ago, 22:03, cricket zijn.digi...@gmail.com wrote: On Tue, Aug 24, 2010 at 7:57 PM, DerBjörn b.unkh...@googlemail.com wrote: Thanks j, for your example and your suggestions. I think I will go with the tinyint. What about the idea to use is_state_capital and is_capital? Wouldnt this solve the problem? This looks like it's getting really complicated for nothing. These tinyint columns seem like a bad hack. As I mentioned earlier, you can do this simply with virtual models, NationalCapital and StateCapital. Each would use classname City. Can a city be capital of a country and not of its state? I dont think so. Can it? cause then one tinyint with 1 as state capital and 2 as capital of country would be enough. and an unique key(state_id, is_capital)... Of course it can. Ottawa is a good example. Toronto is the Ontario provincial capital. 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: Performance Problems using remote database
jmn2k1, sometimes even the network routing messes with database access speed... We had a problem in which every request passed by the firewall, even to our own servers! The firewall couldn't handle the traffic, therefore everything (internet and intranet access) was so slow. On Aug 13, 11:17 am, jmn2k1 jmn...@gmail.com wrote: Not necessarily your case but once I had a similar problem, it turns out I was using a hostname for the database server that need to do a DNS checkout and hence slow the app down. If you're using the ip then this is not the case. On Aug 12, 10:14 am, Thiago Elias thiagopt...@gmail.com wrote: Hey Guys.. Thanks everyone for the answers.. I'll try them all here today, and I'll post the results soon as possible.. 2010/8/12 djogo djogopat...@gmail.com Hi Thiago, I would try to replicate the entire system (lampp + your app + database) in other server and check whether the slowness is due to the server or not. You may also replicate a legacy PHP app, as you call it, to check if it works well too. This replicated server will allow you to test other experiments without jeopardizing your real production data. If the performance in the replicated server is equivalent to your original one, check if its something in the cakephp lib. Create a controller that doesn't use any models at all. If it's also slow, than the problem is something about your cake, or its configuration. If it's not, then it's probably your database. Then you can start thinking about database optimization. Is all queries slow? Try a simple SELECT 1 FROM DUAL in the legacy PHP and in cakePHP. how many milisseconds each one takes (test both on the browser)? Is AppController-beforeFilter doing something that may be slowing down your queries? Turn debug to 2 and for each query that it reports, check how much time is it taking (it's right beside the query name). Try to run the same query on the database directly and check if the timing is compatible. When my apps turn slow, I always think of the DB. Sometimes, it's just a matter of creating the right indexes - for instance, if you run SELECT marafo_id, count(*) from naosei group by marafo_id, it'll be really slow when you have lots (100K) of rows and the grouped column is not indexed. A simple CREATE INDEX index_naosei_marafo_id ON naosei (marafo_id); would solve this problem. Well, keep us all informed about these results. I'm very interested because every once in a while I (and may I add, everybody =]) run into this kind of problem too. dfcp On 11 ago, 22:29, Thiago Elias thiagopt...@gmail.com wrote: Hi All, Since two or three months ago (more or less), I'm experiencing some problems involving CakePHP. In the past, our application was using a local database connection, and performance was really nice and acceptable. Some months ago, we had to migrate the application to another server, separating the Data and the Apps. After this change, I've lost performance in my cake App. Each request takes around 10 ~ 15 seconds, and before, was 2 ~ 3,5 secs. The interesting thing is: The other legacy PHP Apps are 100% fast, and even other cakeAPPs are fast too, but the difference is: My main cake app (the one that lost performance) have 80 innoDB Tables and 20 views. (used to link to another databases). I'm using CakePHP 1.2.7, PHP 5.2. And in the Database Server, MySQL Server 5.1. Our network infrastructure is really fast, and ping response between servers is really nice. Does anyone knows why I'm losing performance just in this App when connected to a remote server ?! I'm using CakePHP Debug, and ~85% of the time spent in the request is lost in the CORE, and not in the app. (The core is the same of the other cakeApps..) Please help-me (and sorry for my bad english). Thiago Elias Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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: Performance Problems using remote database
Hi Thiago, I would try to replicate the entire system (lampp + your app + database) in other server and check whether the slowness is due to the server or not. You may also replicate a legacy PHP app, as you call it, to check if it works well too. This replicated server will allow you to test other experiments without jeopardizing your real production data. If the performance in the replicated server is equivalent to your original one, check if its something in the cakephp lib. Create a controller that doesn't use any models at all. If it's also slow, than the problem is something about your cake, or its configuration. If it's not, then it's probably your database. Then you can start thinking about database optimization. Is all queries slow? Try a simple SELECT 1 FROM DUAL in the legacy PHP and in cakePHP. how many milisseconds each one takes (test both on the browser)? Is AppController-beforeFilter doing something that may be slowing down your queries? Turn debug to 2 and for each query that it reports, check how much time is it taking (it's right beside the query name). Try to run the same query on the database directly and check if the timing is compatible. When my apps turn slow, I always think of the DB. Sometimes, it's just a matter of creating the right indexes - for instance, if you run SELECT marafo_id, count(*) from naosei group by marafo_id, it'll be really slow when you have lots (100K) of rows and the grouped column is not indexed. A simple CREATE INDEX index_naosei_marafo_id ON naosei (marafo_id); would solve this problem. Well, keep us all informed about these results. I'm very interested because every once in a while I (and may I add, everybody =]) run into this kind of problem too. dfcp On 11 ago, 22:29, Thiago Elias thiagopt...@gmail.com wrote: Hi All, Since two or three months ago (more or less), I'm experiencing some problems involving CakePHP. In the past, our application was using a local database connection, and performance was really nice and acceptable. Some months ago, we had to migrate the application to another server, separating the Data and the Apps. After this change, I've lost performance in my cake App. Each request takes around 10 ~ 15 seconds, and before, was 2 ~ 3,5 secs. The interesting thing is: The other legacy PHP Apps are 100% fast, and even other cakeAPPs are fast too, but the difference is: My main cake app (the one that lost performance) have 80 innoDB Tables and 20 views. (used to link to another databases). I'm using CakePHP 1.2.7, PHP 5.2. And in the Database Server, MySQL Server 5.1. Our network infrastructure is really fast, and ping response between servers is really nice. Does anyone knows why I'm losing performance just in this App when connected to a remote server ?! I'm using CakePHP Debug, and ~85% of the time spent in the request is lost in the CORE, and not in the app. (The core is the same of the other cakeApps..) Please help-me (and sorry for my bad english). Thiago Elias 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: cake 1.3.2 wants to be too smart
Cricket, that was what you meant? http://teknoid.wordpress.com/2009/03/11/blacklist-your-model-fields-for-save/ If so, yeah, that would do it, with just a tweak on beforeSave. Good call. AD7six, I solved my problem by, alas, giving it up and writing everything on beforeSave. I'll check if it has been already ticketed and maybe write a patch to try and solve this problem. However, I think it's a MySQL issue. I don't have any idea if this discussion applies to other DBs like postgreSQL, Firebird, as I don't have much knowledge of these. On 17 jul, 12:26, AD7six andydawso...@gmail.com wrote: On Jul 16, 6:08 pm, djogo djogopat...@gmail.com wrote: yeah, it's so stupidly easy to do it in MySQL, it's a shame that I have to write any code at all in beforeSave() to accomplish the same thing. RAPID DEVELOPMENT, they say. Maybe the model could have a no-mess-field-list, or fields that will be left alone when saving or updating. If you're writing any code at all to fix this issue it should be in a test case and patch. Cake's goal is to not repeat code/process-logic that includes not doing something in php which you're already doing/ capable of doing in the DB layer (and it's just a consequence of CURRENT_TIMESTAMP not being understood correctly). If you already ticketed this please link to it from this thread. Cheers, AD 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: cake 1.3.2 wants to be too smart
yeah, it's so stupidly easy to do it in MySQL, it's a shame that I have to write any code at all in beforeSave() to accomplish the same thing. RAPID DEVELOPMENT, they say. Maybe the model could have a no-mess-field-list, or fields that will be left alone when saving or updating. On 15 jul, 03:30, Grzegorz Pawlik grzegorzpaw...@gmail.com wrote: Ofcourse I could, but I don't like to repeat myself. If I have this functionality in DB - I don't want to implement it in my scipts. This is not about that I can not continue because of that cake behavior. I can get a simple workaround working. This is more about concepts, principles behind cake and undocumented(?) behaviors. On 15 July 2010 06:33, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: I don't know if this would work for you and your set up, but could you populate and set the timestamp from within Cake using the date() function instead of relying on the database? Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 15 Jul 2010, at 05:26, djogo wrote: Yes, this kind of suck. I wanted to have both created_at and updated_at fields, which I remember being trivial at mysql, but cake doesnt allow you to: - have two or more timestamp fields - name your timestamp field whatever you want On 13 jul, 04:11, Grzegorz Pawlik grzegorzpaw...@gmail.com wrote: That's not what I'm asking about. Lets say I NEED to use TIMESTAMP and CURRENT_TIMESTAMP as default value, and in that case cakePHP misbehaves. On Jul 13, 7:04 am, Walther waltherl...@gmail.com wrote: I've never seen that problem before... Cake offers the same functionality, it is well documented in every book. Basically you crater a field called created or updated as a datetime, default null and cake will populate it automatically. On Jul 12, 5:02 pm, Grzegorz Pawlik grzegorzpaw...@gmail.com wrote: just switching from 1.3.0 to 1.3.2 got me into trouble, when I have field specified as: `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP and don't supply any value for that field in array I try to save , neither a key in 1.3.0 it's working as desired - I get current timestamp in that field, but 1.3.2 tries looks that's it not null field, and read default value (CURRENT_TIMESTAMP) ant unfortunatelly polupulates this array with that pair of key/val: createt_at=CURRENT_TIMESTAMP which is basically stupid for two reasons, I think: 1. It tries to duplicate database mechanisms which are working just fine (when no value - use default value, no need to to that: if no value, check what's default value defined in database and explicitly save data with that value) 2. It makes CURRENT_TIMESTAMP not working is there a way to turn that behavior off? Check out the new CakePHP Questions sitehttp://cakeqs.organd 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions sitehttp://cakeqs.organd 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en -- Grzegorz Pawlik 695 146 983 grzegorzpaw...@gmail.com 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: cake 1.3.2 wants to be too smart
Yes, this kind of suck. I wanted to have both created_at and updated_at fields, which I remember being trivial at mysql, but cake doesnt allow you to: - have two or more timestamp fields - name your timestamp field whatever you want On 13 jul, 04:11, Grzegorz Pawlik grzegorzpaw...@gmail.com wrote: That's not what I'm asking about. Lets say I NEED to use TIMESTAMP and CURRENT_TIMESTAMP as default value, and in that case cakePHP misbehaves. On Jul 13, 7:04 am, Walther waltherl...@gmail.com wrote: I've never seen that problem before... Cake offers the same functionality, it is well documented in every book. Basically you crater a field called created or updated as a datetime, default null and cake will populate it automatically. On Jul 12, 5:02 pm, Grzegorz Pawlik grzegorzpaw...@gmail.com wrote: just switching from 1.3.0 to 1.3.2 got me into trouble, when I have field specified as: `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP and don't supply any value for that field in array I try to save , neither a key in 1.3.0 it's working as desired - I get current timestamp in that field, but 1.3.2 tries looks that's it not null field, and read default value (CURRENT_TIMESTAMP) ant unfortunatelly polupulates this array with that pair of key/val: createt_at=CURRENT_TIMESTAMP which is basically stupid for two reasons, I think: 1. It tries to duplicate database mechanisms which are working just fine (when no value - use default value, no need to to that: if no value, check what's default value defined in database and explicitly save data with that value) 2. It makes CURRENT_TIMESTAMP not working is there a way to turn that behavior off? 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: Change __() default behavior
Hello I asked the same thing some time ago, in this thread (couldn't find googlegroups link, sorry) http://www.mail-archive.com/cake-php@googlegroups.com/msg79031.html Somebody said it was in the developer's plans, but still... I thought about creating ___(), but it's a lot of keystrokes. Also, I'm not sure whether the string extraction script would work that way, and that's one of the good things about _() or __(). Is it possible to undefine __() [ or maybe _() ] and redefine it in boostrap.php (pun intended) ? I think it would be better. On Mar 23, 12:52 am, xtraorange xtraora...@gmail.com wrote: Thanks! :) (I liked boostrap.php better, but I followed what you were saying. :P) On Mar 22, 10:23 pm, nurvzy nur...@gmail.com wrote: Whops... boostrap.php = bootstrap.php Just incase you were confused. lol Nick On Mar 22, 9:21 pm, nurvzy nur...@gmail.com wrote: Put it in app/config/boostrap.php You'll have access to it throughout your app. Nick On Mar 22, 8:06 pm, xtraorange xtraora...@gmail.com wrote: That's actually exactly what I was just thinking of doing, lol. Thanks! The only thing I can't find... where am I supposed to place a function that I want available both on the control and view levels? On Mar 22, 8:59 pm, Gonzalo Servat gser...@gmail.com wrote: On Tue, Mar 23, 2010 at 12:44 PM, xtraorange xtraora...@gmail.com wrote: Howdy all, This should be a quick one: Is there any way, without editing the cake core (so that upgrades are easy), to switch the default behavior of __() from by default echoing, to by default returning? I find that 99% of the time, I don't want it to echo, and it's annoying to add the true parameter in there every single time. What about creating a new function like ___() that calls __() with the true parameter? Regards Gonzalo 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: disabling cache when a user is logged
Euromark, I think that __construct is the first thing that runs in Any class, so sessions are avaliable in all methods. I thought of using it at bootstrap, but there the session is unavailable... On 31 jan, 20:29, euromark dereurom...@googlemail.com wrote: this will never work the session is initialized in __construct() of the app controller therefore not available until beforeFilter() in any controller the session will not be present at that time yet or am i mistaken? On 31 Jan., 22:09, majna majna...@gmail.com wrote: dirty way (not tested) in app/config/bootstrap.php check if user is logged in, like: if (isset($_SESSION['User']['id])) { Configure::write('Cache.check', false); } On Jan 31, 11:32 am, Lorenzo Bettini bett...@dsi.unifi.it wrote: Hi in my AppController I've enabled cache for view and index actions and they work fine. Now, I'd like to disable cache when a user is logged, since in that case additional information are shown that must not be cached. Thus I added the method function beforeRender() { if ($this-is_logged_user()) { // disable cache when the user is logged, since some information // must NOT be cached, e.g., private papers $this-cacheAction = array(); } } where is_logged_user is a function that checks whether a user is logged. This works in the sense that no cache is used when a user is browsing the site. However, if the user visits an action page which has already been cached then he will get the cached page, which I want to avoid as well... is there a way to avoid this? I've also tried with $this-disableCache() but that does not work. The only solution I see is to clear the cache, but I'd want to avoid that... thanks in advance Lorenzo -- Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com 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: how to call Model1-find(all) from Model2 Controller
Yes, but, why is uses evil? The post simply says dont use it, and not explains why, or when it's adviseable to. I presume,by the post title, that that's because it's slow. How slow? dfcp On 19 jan, 04:47, Walther waltherl...@gmail.com wrote: Never use $uses unless you really really really have too. See here:http://www.pseudocoder.com/archives/2009/04/16/one-more-tip-for-speed... Rather use $this-loadModel or ClassRegistry::init On Jan 18, 12:34 pm, djogo djogopat...@gmail.com wrote: Class usercontroller extends appcontroller { Var $uses=array( 'Users','Projects'); } Then you can use $this-Project-find() On 17 jan, 08:10, codef0rmer amit.2006...@gmail.com wrote: thx guys. Finally, it worked :) 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: how to execute this query with cakephp
When you run a query like this, you're violating MVC practise. I'd rather $x = $model-find() $x['Model']['field']++ $model-save($x) To keep things were they're supposed to be, otherwise sometimes queries are at the model, sometimes at controller, next thing you know you're writing stored procedures; and that's a nightmare. Of course, sometimes you need speed, so I'd Write a method like wyrihaximus did. On 18 jan, 07:55, WyriHaximus webmas...@wyrihaximus.net wrote: Afaik not thats why I wrote this function for in my appModel a while ago:http://bin.cakephp.org/view/429049354 On Jan 18, 2:52 am, Saleh Souzanchi saleh.souzan...@gmail.com wrote: Is there another way? On Jan 18, 4:46 am, Jon Bennett jmbenn...@gmail.com wrote: how to execute this query with cakephp : update table_name set hit = hit+1 $this-Table-query('update table set hit = hit+1); j -- jon bennett -www.jben.net-blog.jben.net 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: how to call Model1-find(all) from Model2 Controller
Class usercontroller extends appcontroller { Var $uses=array( 'Users','Projects'); } Then you can use $this-Project-find() On 17 jan, 08:10, codef0rmer amit.2006...@gmail.com wrote: thx guys. Finally, it worked :) 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: Default __() parameters causes problems
That's good news indeed. In which version this feature is planned to be in? I guess I'll just use a patched version of cake 1.2.5 until this version comes out. On Dec 17, 10:45 pm, euromark dereurom...@googlemail.com wrote: nice to hear that especially as it is used in controllers, components etc too and there the echo default is not that much used :) On 17 Dez., 19:47, Larry E. Masters aka PhpNut php...@gmail.com wrote: I have plans to change the __*() functions to return by default it has not been implemented yet -- /** * @author Larry E. Masters * @var string $userName * @param string $realName * @returns string aka PhpNut * @access public */ On Thu, Dec 17, 2009 at 12:31 PM, euromark dereurom...@googlemail.comwrote: i do agree that this is one of the few remaining inconsistencies remaining in cake1.2/1.3 all other functions return by default e.g. in 1.3 the flash() messages now are returned by default, although scripts/css are inline by default (and therefore echod too). returning should be the default value in most cases but i dont think in the __() case this is going to happen :) at least it doesnt look like it using the ___() function might be a very neat way of fixing it for you, though the overhead is minimal you should then use the second param though! function ___($a, $return = true) { return __($a, $return); } to be more flexible On 17 Dez., 18:39, djogo djogopat...@gmail.com wrote: Our previous, cake1.1, code was internationalized using php's gettext library and the function _(). Cake1.2 now uses __(), which is great, because doesn't require us to compile .po files anymore. However, the default behaviour of __() is to echo the translated string, instead of returning it, therefore I'm having a lot of heavy work going from _( $a ) to __( $a, true ). I have a regexp for translating _() to __(), but I couldn't figure out how to insert the ,end parameter in the end of the call. I though to create a patch in the __() function to change the default value, but I don't want to have my own version of cakephp. Or, I may create function ___($a) { return __($a,true); } I _really_ think cakephp designers should make the second parameters true by default, to turn the transition easy. However, I need my code functioning in CAKE 1.2. Do anybody have some tip? Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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: Default __() parameters causes problems
Yes we're getting issues. Specially when we use __ and sprintf combined, as in ?= sprintf( __( Username: %s), $username ) ? In cake1.2 it renders: djogo Username:%s Speaking of that, I would like to post a (perl) script I used to change _(..) to __(..). It would be improved, adding (or removing) a ,true) to the end of the call. #!/usr/bin/perl open H, $ARGV[0] or die cant open $ARGV[0]\n; open I, $ARGV[0].mod; while(H) { s/^_\s*\(/__\(/g; s/([^_])_\s*\(/\1__\(/g; print I; } close I; close H; rename( $ARGV[0], $ARGV[0].bak ); rename( $ARGV[0].mod, $ARGV[0] ); On Dec 18, 2:04 pm, euromark dereurom...@googlemail.com wrote: the switching process will be causing quite a few new bugs i imagine :) at least without really good regexp substitutions On 18 Dez., 16:43, djogo djogopat...@gmail.com wrote: That's good news indeed. In which version this feature is planned to be in? I guess I'll just use a patched version of cake 1.2.5 until this version comes out. On Dec 17, 10:45 pm, euromark dereurom...@googlemail.com wrote: nice to hear that especially as it is used in controllers, components etc too and there the echo default is not that much used :) On 17 Dez., 19:47, Larry E. Masters aka PhpNut php...@gmail.com wrote: I have plans to change the __*() functions to return by default it has not been implemented yet -- /** * @author Larry E. Masters * @var string $userName * @param string $realName * @returns string aka PhpNut * @access public */ On Thu, Dec 17, 2009 at 12:31 PM, euromark dereurom...@googlemail.comwrote: i do agree that this is one of the few remaining inconsistencies remaining in cake1.2/1.3 all other functions return by default e.g. in 1.3 the flash() messages now are returned by default, although scripts/css are inline by default (and therefore echod too). returning should be the default value in most cases but i dont think in the __() case this is going to happen :) at least it doesnt look like it using the ___() function might be a very neat way of fixing it for you, though the overhead is minimal you should then use the second param though! function ___($a, $return = true) { return __($a, $return); } to be more flexible On 17 Dez., 18:39, djogo djogopat...@gmail.com wrote: Our previous, cake1.1, code was internationalized using php's gettext library and the function _(). Cake1.2 now uses __(), which is great, because doesn't require us to compile .po files anymore. However, the default behaviour of __() is to echo the translated string, instead of returning it, therefore I'm having a lot of heavy work going from _( $a ) to __( $a, true ). I have a regexp for translating _() to __(), but I couldn't figure out how to insert the ,end parameter in the end of the call. I though to create a patch in the __() function to change the default value, but I don't want to have my own version of cakephp. Or, I may create function ___($a) { return __($a,true); } I _really_ think cakephp designers should make the second parameters true by default, to turn the transition easy. However, I need my code functioning in CAKE 1.2. Do anybody have some tip? Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 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.comcake-php%2bunsubscr...@googlegroups.comFor more options, visit this group at http://groups.google.com/group/cake-php?hl=en 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
Default __() parameters causes problems
Our previous, cake1.1, code was internationalized using php's gettext library and the function _(). Cake1.2 now uses __(), which is great, because doesn't require us to compile .po files anymore. However, the default behaviour of __() is to echo the translated string, instead of returning it, therefore I'm having a lot of heavy work going from _( $a ) to __( $a, true ). I have a regexp for translating _() to __(), but I couldn't figure out how to insert the ,end parameter in the end of the call. I though to create a patch in the __() function to change the default value, but I don't want to have my own version of cakephp. Or, I may create function ___($a) { return __($a,true); } I _really_ think cakephp designers should make the second parameters true by default, to turn the transition easy. However, I need my code functioning in CAKE 1.2. Do anybody have some tip? 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: autocomplete with id and value
I added some attributes to the li tag, so the callback function would access them. For instance li my_id=33is it a hack?/li Then i use getAttribute to access it. I made a lot of this to replace huge select boxes, but if you ask me, I'd advise otherwise, because on production with a lousy network, the autocomplete is so slow and unresponsive. Users actually asked for the select boxes back! Dfcp On 11 dez, 20:51, paulinthought paulgrat...@gmail.com wrote: Hi, I have autocomplete working fine, it passes the value of the selected field back to the controller once I post it but I can't guarantee the values in my list will be unique so I need to identify each with an id and pas that back to the controller also. I've found some samples which involve putting the id and the value into the display list. There must be a more elegant way to do this! Can anyone help? 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: How to use 1 controller in another controller?
Either your controller is doing a model`s job (eg. preprocessing some data prior to insert/update), a component`s job, or what you really need is to redirect the browser to /posts_controller/add/. try this: look at the code at posts-add, extract the portion that you need to be run in both controllers, and put it in a new method of the Posts (I guess) model, like myAdd, which calls the regular save method. Then you call myAdd directly from the controllers you`re talking about. On Oct 9, 4:06 pm, mscdex msc...@gmail.com wrote: On Oct 9, 1:27 pm, Aivaras faifas1...@gmail.com wrote: Hey, App::import('Controller', 'PostsController'); $this-Posts = new PostsController(); $this-Posts-add($this-data); Cheers, Aivaras I would strongly recommend you re-think how you're going about this. However, if worst comes to worst and you cannot for some reason re- structure your application, you could use requestAction:http://book.cakephp.org/view/434/requestAction --~--~-~--~~~---~--~~ 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: Just curious question
You shouldn't pull BLOB or whatever large data you got. It's better if you keep it in a separate table. If you have fields that are empty in many records, I also advocate that it's good practice to keep another table for them - even if the relationship is 1:1. This way you alway retrieve the desired data. On Sep 26, 8:11 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Yeah that looks like a nifty approach, Will give that a shot! Thanks I am just cleaning up my app I have been playing round with over the last few months so as I learn to make things better and evolve I see functions I have made where some grab 3 fields, some grab all, other 10 or so. So there is a mess of functions grabbing specific data, all data, little data so was just wondering how other people do it. But you idea would allow me to use the same function and grab what I need / don’t need. I think I may expand on your idea and create it where you can choose to 'keep' or 'remove' fields rather than having to type 20 names to keep only type out the few you don’t need or what not and use something like array_diff_key or array_intersect_key to keep or remove based on $this-myFields = array('field_one, 'field_two', 'and_some_other'); Dave -Original Message- From: teknoid [mailto:teknoid.cake...@gmail.com] Sent: September-26-09 6:29 PM To: CakePHP Subject: Re: Just curious question ... haven't tested, but something like this should work: In the model: $this-myFields = array('field_one, 'field_two', 'and_some_other'); public function modifyRequiredFields($additionalFields) { array_push($this-myFields, $additionalFields); return $this-myFields; } In the controller: $this-ModelName-find('all', array('fields' = $this-ModelName- modifyRequiredFields(array('i_also_need_this', 'and_this')); ... or ... if it's a standard find() $this-ModelName-find('all', array('fields' = $this-ModelName- myFields)); On Sep 26, 3:14 pm, Dave Maharaj :: WidePixels.com d...@widepixels.com wrote: Just wondering if anyone has an opinion or fact about this. When pulling model data, keep it simple so Users controller getting straight info from Users database. Users table has 15 fields. You may only need 5 fields data and in another case you may need all 15 fields. Is it best to specify the fields you need always? I guess the size of the data in the fields will make a difference. I am just thinking in regards to my app where i need a few fields, then i need all fields does it take more time to process a detailed request when you specify each individual field when you need info from 10 fields as opposed to *just and get them all. What is best practise? Or in this case its more of a try both and see what works best for each app? Thanks Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Variable substitution
Hi , What do you mean by that? On Sep 16, 1:06 pm, euromark (munich) dereurom...@googlemail.com wrote: in this case it is a neccessary abstraction of the DB structure On 16 Sep., 13:36, djogo djogopat...@gmail.com wrote: Yeah, String::insert is more like what I'm looking for. However, what I really wanted to see is something that allows me to substitute something model-like. Let`s say $a = $this-Article-findById(88); $u = $this-User-findById(21); $m = $this-MessageTemplate-findById( 45 ); $this-MessageComponent-send( $u, $m, $a ); so MessageComponent::send is receiving three arrays from models, so $a could be like $a['Article']['name'] = '' $a['Author'][0]['name'] = 'dfajodsijo' $a['Author'][1]['name'] = 'dskpfokp' And in my message template, I could just say Hello, :$u['User'] ['name'], here is the article $a['Article']['name'] wrote by $a ['Author'][0]['name'] and $a['Author'][1]['name'] that the proper values would fall into places. And my messages placeholders would not have to follow a different nomenclature than it is done in the models. In order to use String::insert, I'd need to map things first, like array( ':username'=$u['User']['name'], ':articlename' =$a['Article'] ['name'] ). And I think it's an unnecessary step. What do you think? Thanks!! On Sep 16, 12:06 am, Dr. Loboto drlob...@gmail.com wrote: As all above said, you need placeholders and nothing more. Check String::insert()http://api.cakephp.org/class/string#method-Stringinsert to get nice wrap around boring str_replace. On Sep 15, 8:09 pm, djogo djogopat...@gmail.com wrote: All messages, emails, and receipts that my system sends are stored in a database table. This way, system administrators are able to customize these messages without having to interact with programmers. Therefore, I need generic placeholders. I could write a hundred substr (), for each message type needs different variables (lost password email needs user info, project submission receipt needs project data, and there you go) That's why I wanted to perform var subst in a variable contents.I don't need code evaluation (bad practice, as pointed outra). Dfcp On Sep 14, 9:49 pm, euromark (munich) dereurom...@googlemail.com wrote: thats what bbcode, placeholders etc. and sprintf(), replace functions etc. are for On 14 Sep., 20:11, brian bally.z...@gmail.com wrote: On Mon, Sep 14, 2009 at 8:06 AM, djogo djogopat...@gmail.com wrote: That's exactly the point, I want it to be in a database column, and allow the end-user to edit it. Therefore, $test would keep a HTML/RTF document with tags ?=?. I want to get it, perform variable substitution, and then e-mail it, or save it in another database column, but I just don't want to display it. What do you mean by allow the end-user to edit it? What, exactly, are you trying to do? There's surely a better way, whatever it is. --~--~-~--~~~---~--~~ 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: Variable substitution
Yeah, String::insert is more like what I'm looking for. However, what I really wanted to see is something that allows me to substitute something model-like. Let`s say $a = $this-Article-findById(88); $u = $this-User-findById(21); $m = $this-MessageTemplate-findById( 45 ); $this-MessageComponent-send( $u, $m, $a ); so MessageComponent::send is receiving three arrays from models, so $a could be like $a['Article']['name'] = '' $a['Author'][0]['name'] = 'dfajodsijo' $a['Author'][1]['name'] = 'dskpfokp' And in my message template, I could just say Hello, :$u['User'] ['name'], here is the article $a['Article']['name'] wrote by $a ['Author'][0]['name'] and $a['Author'][1]['name'] that the proper values would fall into places. And my messages placeholders would not have to follow a different nomenclature than it is done in the models. In order to use String::insert, I'd need to map things first, like array( ':username'=$u['User']['name'], ':articlename' =$a['Article'] ['name'] ). And I think it's an unnecessary step. What do you think? Thanks!! On Sep 16, 12:06 am, Dr. Loboto drlob...@gmail.com wrote: As all above said, you need placeholders and nothing more. Check String::insert()http://api.cakephp.org/class/string#method-Stringinsert to get nice wrap around boring str_replace. On Sep 15, 8:09 pm, djogo djogopat...@gmail.com wrote: All messages, emails, and receipts that my system sends are stored in a database table. This way, system administrators are able to customize these messages without having to interact with programmers. Therefore, I need generic placeholders. I could write a hundred substr (), for each message type needs different variables (lost password email needs user info, project submission receipt needs project data, and there you go) That's why I wanted to perform var subst in a variable contents.I don't need code evaluation (bad practice, as pointed outra). Dfcp On Sep 14, 9:49 pm, euromark (munich) dereurom...@googlemail.com wrote: thats what bbcode, placeholders etc. and sprintf(), replace functions etc. are for On 14 Sep., 20:11, brian bally.z...@gmail.com wrote: On Mon, Sep 14, 2009 at 8:06 AM, djogo djogopat...@gmail.com wrote: That's exactly the point, I want it to be in a database column, and allow the end-user to edit it. Therefore, $test would keep a HTML/RTF document with tags ?=?. I want to get it, perform variable substitution, and then e-mail it, or save it in another database column, but I just don't want to display it. What do you mean by allow the end-user to edit it? What, exactly, are you trying to do? There's surely a better way, whatever it is. --~--~-~--~~~---~--~~ 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: Variable substitution
All messages, emails, and receipts that my system sends are stored in a database table. This way, system administrators are able to customize these messages without having to interact with programmers. Therefore, I need generic placeholders. I could write a hundred substr (), for each message type needs different variables (lost password email needs user info, project submission receipt needs project data, and there you go) That's why I wanted to perform var subst in a variable contents.I don't need code evaluation (bad practice, as pointed outra). Dfcp On Sep 14, 9:49 pm, euromark (munich) dereurom...@googlemail.com wrote: thats what bbcode, placeholders etc. and sprintf(), replace functions etc. are for On 14 Sep., 20:11, brian bally.z...@gmail.com wrote: On Mon, Sep 14, 2009 at 8:06 AM, djogo djogopat...@gmail.com wrote: That's exactly the point, I want it to be in a database column, and allow the end-user to edit it. Therefore, $test would keep a HTML/RTF document with tags ?=?. I want to get it, perform variable substitution, and then e-mail it, or save it in another database column, but I just don't want to display it. What do you mean by allow the end-user to edit it? What, exactly, are you trying to do? There's surely a better way, whatever it is. --~--~-~--~~~---~--~~ 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: Variable substitution
That's exactly the point, I want it to be in a database column, and allow the end-user to edit it. Therefore, $test would keep a HTML/RTF document with tags ?=?. I want to get it, perform variable substitution, and then e-mail it, or save it in another database column, but I just don't want to display it. dfcp On Sep 13, 12:43 pm, brian bally.z...@gmail.com wrote: This is a bit confusing. Why are you setting the variable $test in the first place? Just put: pHello, b?=$destinatary[Person][name]?/b ... in your view. On Sat, Sep 12, 2009 at 9:33 AM, djogo djogopat...@gmail.com wrote: Hello all, The topic on Smarty remembered me of one issue I got. Suppose I have a string like this: $test = 'pHello, b?=$destinatary[Person][name]?/b'; and I have a variable called $destinatary defined somewhere, and I wish to substitute the substring (contained in $test) ?=$destinatary[Person][name]? for the appropriated value that is into the variable $destinatary ['Person']['name']. Is there any class on cakephp to do it? Yeah, I'm currently using Smarty for that, it allows me to perform variable substitution not only in view files, but also in strings. And I feel that doing something like eval( \$return = \$test\; ); is awfully dangerous, as $test actually comes from database, which is set by the end-user. The only way I though of doing that on Cakephp is by actually writing the $test contents into a view and rendering it, but it's lame. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Variable substitution
Hello all, The topic on Smarty remembered me of one issue I got. Suppose I have a string like this: $test = 'pHello, b?=$destinatary[Person][name]?/b'; and I have a variable called $destinatary defined somewhere, and I wish to substitute the substring (contained in $test) ?=$destinatary[Person][name]? for the appropriated value that is into the variable $destinatary ['Person']['name']. Is there any class on cakephp to do it? Yeah, I'm currently using Smarty for that, it allows me to perform variable substitution not only in view files, but also in strings. And I feel that doing something like eval( \$return = \$test\; ); is awfully dangerous, as $test actually comes from database, which is set by the end-user. The only way I though of doing that on Cakephp is by actually writing the $test contents into a view and rendering it, but it's lame. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: How to use a helper in Controller or Model?
Sometimes people (think they) need formatted data to come out from a model, like date or time. However, if you follow MVC, that must be done at view level. That's where all localization and internacionalization should be done. Same applies to a controller needing to access other controller. You should redirect instead of importing and calling the class. dfcp On Sep 7, 10:11 pm, euromark (munich) dereurom...@googlemail.com wrote: @fahad you should point out that you would need to create the object prior to using it for all those who are not so familiar with that App::import('Helper', 'Html'); $this-Common = new CommonHelper(); $foo = $this-Common-do(); sometimes this is not neccessary if the helper function does something on its own (without refering to other class vars or functions) you can access them statically $foo = CommonHelper::foo(); On 7 Sep., 21:35, Fahad faha...@gmail.com wrote: I wouldn't suggest you use a helper in your controller. but you can do it by importing your desired library. in your controller: App::import('Helper', 'Html'); On Sep 7, 5:14 pm, cogitovn cogit...@gmail.com wrote: Hi all, I'm a newbie in cakePHP. As I know, helper is a part of View. So, how to use a helper in Controller or Model? For example, I want to Html helper, Xml Helper in a controller, in order to call some methods such as, html-url(), xml-serialize() Please help me on detail. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: InnoDB vs. MyISAM, does CakePHP care?
Hello In my experience, cake doesn't care. For 2 years or so I have (in my work) myISAM tables for development, and when my code goes to production, tables are converted to InnoDB and FKs properly created. Never got any problem. If you ask me, I'd say that FKs are nice because it keeps data integrity no matter which way you update it. But in cake, FKs errors are not properly treated, you get a nice red message or nothing (depends on debug level). Cake data validation's way to go, but then you got two places to update (database and models). It would be nice if bake detects FKs automatically. On Aug 14, 6:09 pm, JamesF usaexportexpe...@gmail.com wrote: no i just want to alter my current mysql database to use innodb without affecting the model relationships. it is a trivial thing to change the storage engine but I am not sure of the results. On Aug 14, 5:07 pm, anders als andersa...@googlemail.com wrote: So, you want Cake to use MyISAM syntax for an InnoDB driven sql server? I think this is possible doing some configurations inside of the database related core files On 14 Aug., 22:26, JamesF usaexportexpe...@gmail.com wrote: Whnn I first set up the current app I am using, I chose InnoDB tables for almost any Model that i thought would be related. My thinking was that Cake wouldn't understand the foreign key relationships and it would lead to database integrity problems. I am assuming that Cake doesn't care which storage engine I use in the case of simple model relationships. I am not using transactions or row level locking currently, and more often then not, the CASCADE effect of InnoDB tables has made some of my data go bye-bye. I appreciate that InnoDB prevents me from inserting data with incorrect id's and fk id's but it also deletes child data when i don't want it to (unless i use RESTRICT or SET NULL on that fk). So the crux of my question is this, can I maintain my current app functionality while converting back to MyISAM tables, considering I do not use any advanced InnoDB features? Will Cake still handle my table relationships correctly when I am following proper naming conventions for foreign keys and table names? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cakephp multilingual
Hello Yannis Your system must have the specified locale installed, or else the setlocale function won't work. You can check whether it's working or not by doing this: $l = 'es_ES'; echo trying to set locale to $l...; $x = setlocale( LC_ALL, $l ); echo $x ? locale successfully setbr : couldn't set localebr; In linux, you can check the installed locales by typing, in the terminal # locale -a or by listing the contents from /usr/share/locale/locale.alias (ubuntu) (Don't know how to do it on Windows ou OSX, sorry). The $l variable in the example above should be _exactly_ as listed in the command above, or else setlocale will fail. Hope that helps, dfcp On Jul 29, 7:34 am, Yannis ikasso...@gmail.com wrote: Thank you guys, Djogo, what exactly do you mean here?? - check if the locale is installed in your system. sometimes it's lang.encoding, like pt_BR.UTF-8 instead of pt_BR Where do I check that? On Jul 28, 2:33 pm, djogo djogopat...@gmail.com wrote: Hey I spent many time trying to figure out how to make i18n work... I'm not following this topic realtime, but I'd like to post some tips that would really had helped me back then: - always use utf-8, no matter what's the language you're i18ng - check if the locale is installed in your system. sometimes it's lang.encoding, like pt_BR.UTF-8 instead of pt_BR - do not use non-ascii (?) characters in the source code messages. like, _(Tá certo) won't work with gettext. You'll probably want to use _(Ta certo) - for that reason, if your main language is not english or something that doesn't use non-ascii characters, you'll need to translate it if you want to display the correct words - it's frustrating to try to change the .mo files real-time, as you'll need to reload apache (or whatever) everytime. the reason is that apache likes to keep .mo files cached, and won't reload it unless you shut it down and start it again. that's all I remember for now. hope it helps. fell free to contact me pvtly. dfcp On Jul 28, 5:37 am, leop ponton@gmail.com wrote: I can't see what is causing the problem, but it is a warning rather than an error. It seems to indicate that the code executed okay, but the headers had already been sent. If you have copied pasted the code, you may have picked up a space after the ? in p28n.php (I see by swiping the code that there is one in my fragment). L On Jul 28, 7:29 am, Yannis ikasso...@gmail.com wrote: Hi leop, Thanks for the code. I've used it but I get the following error: Warning (2): Cannot modify header information - headers already sent by (output started at .../config/routes.php:49) [CORE/cake/libs/ controller/components/cookie.php, line 364] If that rings any bell?!?! Looks like the line that is causing this is the p28n.php: $this-change(($this-Cookie-read('lang') ? $this-Cookie-read ('lang') : 'eng')); Have you had 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Cakephp multilingual
Hey I spent many time trying to figure out how to make i18n work... I'm not following this topic realtime, but I'd like to post some tips that would really had helped me back then: - always use utf-8, no matter what's the language you're i18ng - check if the locale is installed in your system. sometimes it's lang.encoding, like pt_BR.UTF-8 instead of pt_BR - do not use non-ascii (?) characters in the source code messages. like, _(Tá certo) won't work with gettext. You'll probably want to use _(Ta certo) - for that reason, if your main language is not english or something that doesn't use non-ascii characters, you'll need to translate it if you want to display the correct words - it's frustrating to try to change the .mo files real-time, as you'll need to reload apache (or whatever) everytime. the reason is that apache likes to keep .mo files cached, and won't reload it unless you shut it down and start it again. that's all I remember for now. hope it helps. fell free to contact me pvtly. dfcp On Jul 28, 5:37 am, leop ponton@gmail.com wrote: I can't see what is causing the problem, but it is a warning rather than an error. It seems to indicate that the code executed okay, but the headers had already been sent. If you have copied pasted the code, you may have picked up a space after the ? in p28n.php (I see by swiping the code that there is one in my fragment). L On Jul 28, 7:29 am, Yannis ikasso...@gmail.com wrote: Hi leop, Thanks for the code. I've used it but I get the following error: Warning (2): Cannot modify header information - headers already sent by (output started at .../config/routes.php:49) [CORE/cake/libs/ controller/components/cookie.php, line 364] If that rings any bell?!?! Looks like the line that is causing this is the p28n.php: $this-change(($this-Cookie-read('lang') ? $this-Cookie-read ('lang') : 'eng')); Have you had 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---