Re: Assigning, accessing and comparing viewVars in a controller...

2009-08-10 Thread brian
On Mon, Aug 10, 2009 at 1:24 PM, geste wrote: > > Brian, > > Many thanks.  I got over a bit of a hump on this on Friday with your > help.  I do of course have another n00b follow up question :) > > I am using the authake plug-in for group-based authorization (this > nice plug-in has been taken ove

Re: Storing arrays in the database (one field many values)

2009-08-10 Thread Rawna
Do I need to set foreign keys (author_id, book_id) to the tables (books, authors)? How do I make my views have multiple selection fields and how do I store them (because they're in an array)? On Aug 7, 10:15 am, Robert P wrote: > Well, if Books can have more than one Author in your system then i

Re: Array help

2009-08-10 Thread Martin Westin
If looping the results start becoming too slow for you, you can force Cake to do a join which will make the whole result disappear if the Post is empty. Nate wrote about it and inspired me to build my own variation. http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-fi

Re: URL some page .../id disappeared ?

2009-08-10 Thread brian
@James I thought at first that looked like a real pain but verbose array linking (finding, routing, containing, etc.) is definitely the way to go, I agree. It's often self-documenting, for one thing. And it goes to the heart of what Cake is, I think. Big kudos to the devs for pulling this togethe

Re: cPanel shared hosting

2009-08-10 Thread brian
That seems like a good method for this instance, where there isn't (likely) to be a bunch of other Cake apps floating around. So, no need to make the libs shareable. On Mon, Aug 10, 2009 at 7:31 PM, thatsgreat2345 wrote: > > I usually have the app still inside the cakephp directory, and then > de

Re: cPanel shared hosting

2009-08-10 Thread brian
That seems like a good way to do it. I'm a big fan of being able to easily switch between versions. I'll package it up like that and see if I can make it work. On Mon, Aug 10, 2009 at 9:50 PM, JamesF wrote: > > my cpanel setup is as follows > > /home/jamesf/ > > is my cpanel accounts directory o

Re: Log Errors when debug = 0?

2009-08-10 Thread David
I see what you mean, but I also want to be able to log the PHP errors (not the framework errors) that come up. As far as I understand, the ErrorHandler class only deals with framework errors, doesn't it? On Aug 10, 7:05 pm, JamesF wrote: > i sometimes set a global constant in my bootstrap.php >

Re: Array help

2009-08-10 Thread joshua
I think you can define a model level filter, it will help you to solve this problem thoroughly. Just an idea of mine. Maybe you can put the filter engine in AppModel.[Client] > {Filter engine} > [Server] [Client] <--- {Filter engine} < [Server] For a temporary solution, I think the loo

Re: Log Errors when debug = 0?

2009-08-10 Thread joshua
It would be better if it can be integrated into cake frame configure. On Tue, Aug 11, 2009 at 10:05 AM, JamesF wrote: > > i sometimes set a global constant in my bootstrap.php > > define('LIVE_SITE', true); > > and any error handling has to check and see if('LIVE_SITE') is true > before > it dec

RE: Array help

2009-08-10 Thread Dave Maharaj :: WidePixels.com
The thing is the Post info is there in the database Scenario: The Post article has access level of 1 User that has an access level of 1 can see the Post and bookmark it. No problem Later the owner of the Post changes the access level to 3the user with level 1 access can no loger see that Po

Re: Array help

2009-08-10 Thread joshua
1. Use a callback function afterFind to loop the return array, remove the empty item.2. How about give a condition when model->find. [CODE] 'conditions' => array(("*not*" => array ( "Post.id" => *null* )), //array of conditions [/CODE] On Tue, Aug 11, 2009 at 10:25 AM, Dave Maharaj :: WidePixels.co

Re: having problem with redirecting. I think.

2009-08-10 Thread armen
JFC. I had a space after the ?> in the model file as well as the controller. I removed it and now it's fixed. I love you brian. -Armen On Aug 10, 7:22 am, brian wrote: > A redirect() causes PHP to send headers to the client, informing it of > a redirect. The client then sends a new request.

Array help

2009-08-10 Thread Dave Maharaj :: WidePixels.com
I have a contain query which produces these results. Basically the user bookmarked a page when they had access. The Owner of the post has changed the level of who can view the Post so in this case this user no longer can view the post hence the missing post data. It was not grabbed because the co

Re: Cakephp accessing files

2009-08-10 Thread JamesF
The way I handle PayPal in my app is to store the shopping cart as an entry in a table called transactions. i use serialize to store all my transaction details, and from the it generates the button code unencrypted. When the PayPal transaction finishes it sends an Instant Payment Notification to m

Re: Log Errors when debug = 0?

2009-08-10 Thread JamesF
i sometimes set a global constant in my bootstrap.php define('LIVE_SITE', true); and any error handling has to check and see if('LIVE_SITE') is true before it decides what to do with an error. http://book.cakephp.org/view/154/Error-Handling On Aug 10, 5:22 pm, David wrote: > Hi guys, > > I wo

Re: Log Errors when debug = 0?

2009-08-10 Thread JamesF
i sometimes set a global flag in my bootstrap.php $live = true; and any error handling has to check and see if($live) is true before it decides what to do with an error. http://book.cakephp.org/view/154/Error-Handling On Aug 10, 5:22 pm, David wrote: > Hi guys, > > I would like to silently w

Re: Recursive directory iterator and sorting

2009-08-10 Thread JamesF
http://us3.php.net/manual/en/function.asort.php On Aug 10, 3:07 am, Alan C wrote: > Does anyone know how to sort the results produced by > recursivedirectoryiterator > > the results I'm getting show all the directory tree for a given > folder, but they are not sorted in any way, what I would li

Re: Problem: belongsTo select pulldown is named for Model, not for the applicable foreign key...

2009-08-10 Thread JamesF
i notice you didn't use hasMany or hasOne in your family model. var $hasMany= array( 'Widget' => array( 'className' => 'Widget', 'foreignKey' => 'family_id', ) ); i assume you have family_id set up as a foreign key in your widget table. of course your

Re: URL some page .../id disappeared ?

2009-08-10 Thread JamesF
@euromark your code is certainly more to the point, but i can't break the habit of verbosely linking all my actions. On Aug 8, 9:53 pm, "euromark (munich)" wrote: > as i said, i would go with JUST "url"=>"/".$this->params['url]['url'] > in this case there is no need to use "action" or the manua

Re: cPanel shared hosting

2009-08-10 Thread JamesF
my cpanel setup is as follows /home/jamesf/ is my cpanel accounts directory on the server /home/jamesf/public_html is where apache serves the webroot stuff i set my cakephp lib stuff into a dir above public_html /home/jamesf/usr/cakedev/cakeversion/cake/ and my app stuff in a seperate folder

Problem: belongsTo select pulldown is named for Model, not for the applicable foreign key...

2009-08-10 Thread azkid
I have a model named Widget, and another named Family. Widget belongsTo Family, and the table associated with Widget has a foreign key in it, called id. This foreign key is non-standard, I know, but it is a legacy application with cake spliced in--so I manually set the foreign key in the associa

Re: pagination part 2

2009-08-10 Thread JamesF
you didn't set posts to your view. in your controller $posts = $this->paginate('Post', $conditions); $this->set('posts', $posts); On Aug 9, 7:46 pm, valuba wrote: > sorry this is part 2, > > and my index.ctp looks like this: > > ...// html/php to show the posts > echo $paginator->prev('« Previ

Re: Pagination: 1 Controller, 2 Actions, how to paginate differently?

2009-08-10 Thread JamesF
set your data to your view like so $data = $this->paginate('MyModel', $conditions); $this->set('data', $data'); $conditions is an array of conditions. On Aug 10, 3:36 pm, DigitalDude wrote: > Hey, > > I have an app where I need to do the following: > > In action 1, I want to paginate the resu

Re: Validating a HABTM relationship

2009-08-10 Thread mcrawford
Hmm, this is not quite right either. Now the associated models do not save... According to http://book.cakephp.org/view/85/Saving-Related-Model-Data-HABTM I should be using $form->input('FunctionalArea') but that doesn't work with the validation. But it does work with the save function. Dave, tha

Re: cPanel shared hosting

2009-08-10 Thread thatsgreat2345
I usually have the app still inside the cakephp directory, and then depending if I have multiple apps on the host depends if I put webroot in subfolders, or just in public_html. Then just have to modify the index.php in the webroot to direct it to the location of cakephp for the root, and then the

Re: cPanel shared hosting

2009-08-10 Thread Alexandru Ciobanu
On 8/10/2009 6:03 AM, brian wrote: > > > To complicate things, I need to access this other site through an IP, > not a domain. If anyone has done this, could you please post some > hints? > > Hi Brian, I've deployed several cake apps on cPanel shared hosting. Nothing to be customized, just d

Ajax Errors

2009-08-10 Thread Tony Thomas
This is something that's so simple, I'm embarrassed to ask. But after a few dozen Google searches, I'm going to swallow my pride and post my question here. I have a simple ajax function in my controller and I want it to return an error is the request is not successful. For example: function ajax

Log Errors when debug = 0?

2009-08-10 Thread David
Hi guys, I would like to silently write errors to error.log when in production mode. It would be useful to catch anything going wrong that I hadn't previously noticed. Any ideas for a way to do this? Thanks! David --~--~-~--~~~---~--~~ You received this message

Unit testing and file uploads

2009-08-10 Thread Fran Iglesias
Hi, I'm working in a plugin for my system to manage uploads. It includes an Uploadable behavior. Is it possible to unit-test the upload part in some way? That is, is there a way to "mock" a file upload to the server. My "B plan" is try to isolate the move_uploaded_file() part into a metho

Pagination: 1 Controller, 2 Actions, how to paginate differently?

2009-08-10 Thread DigitalDude
Hey, I have an app where I need to do the following: In action 1, I want to paginate the result-data with, let's say, a condition 1. In action 2, I want to paginate my results with other conditions. How can I do that? At the moment, I only have the "public $paginate = array()" in my contro

Re: Validating a HABTM relationship

2009-08-10 Thread mcrawford
Ah, I found it in the Form helper... $form->input('Question.FunctionalArea') I need to use the full dot-separated name of the field to get the form field to be what the validation is expecting. On Aug 10, 11:32 am, mcrawford wrote: > Hi, > > I have a model set up like this: > > class Questio

Re: Email Validation in cakephp

2009-08-10 Thread Brendon Kozlowski (Realm)
There are two suggestions: Write a patch and test case to prove there's a limitation with the validation, and give back to the CakePHP project with your own code, or... Write a custom validation (http://book.cakephp.org/view/150/Custom- Validation-Rules) to handle your email fields the way you'd

Re: Using Javascript link

2009-08-10 Thread Sarah
Thank you for your reply. I don't fully understand your advice. I understand that HtmlHelper will expect a relative path from webroot/ img, but if it is already in the 'img' folder, why would I need to pass '/img/' + filename ? Will the javascript code look for the Hover images in the img folde

RE: Validating a HABTM relationship

2009-08-10 Thread Dave Maharaj :: WidePixels.com
Give this site a read over. This is where I found a good example that worked for me validating HABTM http://teknoid.wordpress.com/2008/10/16/how-to-validate-habtm-data/ Dave -Original Message- From: mcrawford [mailto:mcrawf...@gmail.com] Sent: August-10-09 4:03 PM To: CakePHP Subject:

Validating a HABTM relationship

2009-08-10 Thread mcrawford
Hi, I have a model set up like this: class Question extends AppModel { var $name = 'Question'; var $hasAndBelongsToMany = array( 'FunctionalArea' => array('joinTable' => 'question_functions') ); var $validate = array( 'title' => 'no

Re: how to match two form->select?

2009-08-10 Thread Marcelo Andrade
On Sun, Aug 9, 2009 at 5:09 PM, Persivo Cunha wrote: > > Hi, I have two form->select and i want that after option of one be > choice, values of other select change. > > For example, > > select 1: >  option: A >  option: B > > if I choose option A, select 2 will show C and D > if I choose option B,

Re: Assigning, accessing and comparing viewVars in a controller...

2009-08-10 Thread geste
Brian, Many thanks. I got over a bit of a hump on this on Friday with your help. I do of course have another n00b follow up question :) I am using the authake plug-in for group-based authorization (this nice plug-in has been taken over by Marco Sbragi and is on CakeForge: http://cakeforge.org/

expired cache files

2009-08-10 Thread zonium
I am using 'File' cache engine to cache some application data. I know we can set duration for the cache but I wonder when the the expired cache files (in TMP) folder get deleted. Do I have to set-up a cron job to delete the expired cache files? How does cakePHP take care of garbage collection? I w

Help in running a CakePHP core unit (web) test. It's killing my Apache process.

2009-08-10 Thread BrendonKoz
Firstly, my environments: - Windows XP Pro SP3 running Apache 2.2.11 (Win32), PHP 5.2.10, and MySQL 5.0.51b-community-nt - Ubuntu 9.10 beta2 (running on VMWare Player) running Apache 2.2.12, PHP 5.2.10-1ubuntu1 with Suhosin-Patch 0.9.7, and MySQL 5.0.83-0ubuntu1. Both environments are running C

Re: Storing arrays in the database (one field many values)

2009-08-10 Thread Martin Westin
I use serialization when: 1. The array is a preference hash (used for settings in plugins). This is a kind of caching to the db if you will. 2. The array is a very complex or in some other way messy structure that is only stored for logging purposes. One example is the rats-nest called MM7 (SOAP

Re: lazy loading?

2009-08-10 Thread Martin Westin
Typical me. I never got to my real point. I wanted to say that if you are having serious performance problems even while containing queries then that is a bit odd. What is the difference if you bench an action with the unneeded associations commented out completely (which should keep the models f

Re: lazy loading?

2009-08-10 Thread Martin Westin
I haven't noticed any significant problems when lots of Models are loaded like that by Cake as long as they are not being used. (I have over 50 models and probably 1/4 - 1/2 of them are involved in many requests) Of-course it would be better if they were never loaded into RAM. When I use php-cac

Re: sql WHERE NOT EXISTS

2009-08-10 Thread brian
ALternatively, if you are selecting for a particular User and just want to know if it has a Role, just check to see if the Role array is empty in $data. On Mon, Aug 10, 2009 at 11:42 AM, CobaltShark wrote: > > I am not sure if this is what you are looking for, but wouldn't you > get what your loo

Re: sql WHERE NOT EXISTS

2009-08-10 Thread CobaltShark
I am not sure if this is what you are looking for, but wouldn't you get what your looking for (and avoid the subquery) by WHERE'ing roles.id IS NULL? Maybe I am misunderstanding what data you are trying to pull as the "where user_id = 3" in the subquery is a bit confusing to me, are you running th

clearCache() unexpected behavior

2009-08-10 Thread Martin Westin
Hi, I like posting here before adding anything to trac to get some feedback first. clearCache() in basics.php does clearing up of specific cache files. I have been under the impression that it was not necessary for me to check the existence of the cached file first but it looks like I have to. It

Re: Using usort in Cake

2009-08-10 Thread John R
Perfect, thank you. On Aug 10, 9:32 am, brian wrote: > Try the Set > class.http://book.cakephp.org/view/640/Sethttp://blogs.bigfish.tv/adam/2008/03/24/sorting-with-setsort-in-cakep... > > > > On Mon, Aug 10, 2009 at 9:46 AM, John R wrote: > > > I have an array that I need to sort by an associ

Re: Storing arrays in the database (one field many values)

2009-08-10 Thread CobaltShark
It is always a bad idea to try and squeeze lists into a single field. It will inevitably lead to you pulling your hair out in the future. Anyone who is tempted to store comma separated lists in a field because its 'easier' should spend a few minutes reading about database normalization. http://de

Re: lazy loading?

2009-08-10 Thread euromark (munich)
thanks for your reply i cant see though, what "containable" has to do with it with containable (what i use globally through app_model by default) you can narrow down the result but it is not the result i am worrying about those classes above (and therefore as many objects?) are included anyway a

Re: Using usort in Cake

2009-08-10 Thread brian
Try the Set class. http://book.cakephp.org/view/640/Set http://blogs.bigfish.tv/adam/2008/03/24/sorting-with-setsort-in-cakephp-12/ On Mon, Aug 10, 2009 at 9:46 AM, John R wrote: > > I have an array that I need to sort by an associative key. PHP's usort > () function is what I need, however it wo

Re: having problem with redirecting. I think.

2009-08-10 Thread brian
A redirect() causes PHP to send headers to the client, informing it of a redirect. The client then sends a new request. The "headers already sent" msg happens when PHP has already started output. You'll have to look in your files for any whitespace outside of the or an echo call or something simi

Re: Flash file not visible at header position

2009-08-10 Thread brian
I meant the *relevant* code. Wading through that, it looks to me that the problem is probably that your paths are wrong. Where is index.php? Where is this 'templates' dir? And where is header.swf? Is it inside the templates/socialbug/html dir? On Mon, Aug 10, 2009 at 7:29 AM, ninad ajnikar wrote:

Re: MISSING TABLE

2009-08-10 Thread Martin Westin
I saw this tiny detail that looks odd: "Error: Database table fams s for model Fams was not found." Somewhere you are referencing a Model called "Fams" which tries to load a table calles "fams s". That is the missing table. Check everywhere for any reference to Fams at all, one of them should pro

Re: Pagination error [ book.cakephp.... example]

2009-08-10 Thread brian
Try this var $paginate = array( 'Post' => array ( 'limit' => 3, 'order' => array( 'Post.id' => 'asc' ) ) ); On Sun, Aug 9, 2009 at 7:41 PM, valuba wrote: > > I think I'm making some obvious faults in my attem

Re: Inter Model Communication

2009-08-10 Thread Martin Westin
Depends on what you want. For simple things I have done a few "manual" things. For example: ModelA needs to tell ModelB to perform some general action: $model =& ClassRegistry::init('ModelB'); $model->doYourThing(); For more complete event handling you could check out: http://cakealot.com/20

Using usort in Cake

2009-08-10 Thread John R
I have an array that I need to sort by an associative key. PHP's usort () function is what I need, however it won't work inside a controller. Example: function cmp($a, $b) { return strcmp($a["fruit"], $b["fruit"]); } $fruits[0]["fruit"] = "lemons"; $fruits[1]["fruit"] = "apples"; $fruits[2]

Re: lazy loading?

2009-08-10 Thread Martin Westin
I think you may be on a different level to that trac note. You would have to confirm the following but I believe this is generally correct: Cake does lazy loading of the classes... classes never referenced during a request will not be included, loaded and instantiated. Cake does no lazy loading

Inter Model Communication

2009-08-10 Thread Abhishek
Hi, Is it possible to have inter model communication. If yes, how do i go about it Regards Abhishek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@goog

Re: MISSING TABLE

2009-08-10 Thread Fran Iglesias
I think you forgot to define a 'prefix' key in the database configuration if all tables must have a prefix in their names. Another solution if that's not he case: in the model add a var $useTable = 'cc_works_collections' Hope that helps El 09/08/2009, a las 23:01, JuanWalker escribió: > Hi

Pagination error [ book.cakephp.... example]

2009-08-10 Thread valuba
I think I'm making some obvious faults in my attempt to create pagination. I followed the blog tut on cakePHP without any problems and decided to follow the pagination examples (http://book.cakephp.org/view/164/Pagination) as well. So my posts_controller.php looks like this: array ('limit' =>

MISSING TABLE

2009-08-10 Thread JuanWalker
Hi Guys, I've this problem. I've a table called cc_works_collections that I've created on mysql db. These are the controller and the model of this table (Using scaffold) class WorksCollectionsController extends AppController { var $name = 'WorksCollections'; var $scaffold; } c

console cant connect to the database

2009-08-10 Thread ondrobaco
hello, im trying to bake an application. the database is installed and the cakephp screen saying that the application can connect to mysql. when i tried to bake the models using console, it says that it the database doesnt have a tables (which it does) and comes up with this error message: What w

Re: MISSING TABLE

2009-08-10 Thread JuanWalker
Has anyone solved this I can't find the solution and the problem is not with quotes On 21 jul, 11:24, brian wrote: > What sort of quotes do you have in 'Fams'? There's an 'undefined > constant' error there, suggesting your quotes aren't correct. Perhaps > they're the "fancy" kind? Don't edit scr

Recursive directory iterator and sorting

2009-08-10 Thread Alan C
Does anyone know how to sort the results produced by recursivedirectoryiterator the results I'm getting show all the directory tree for a given folder, but they are not sorted in any way, what I would like is an alphabetic sort of each level. --~--~-~--~~~---~--~

pagination part 2

2009-08-10 Thread valuba
sorry this is part 2, and my index.ctp looks like this: ...// html/php to show the posts echo $paginator->prev('« Previous ', null, null, array('class' => 'disabled'));6.echo $paginator->next(' Next »', null, null, array ('class' => 'disabled')); (exactly like the tut) I'm receiving an er

Re: CakePHP (and other leading php frameworks) vs. Drupal custom modules

2009-08-10 Thread Smelly Eddie
I think robert and paris have done a good job answering this. Cake <> Drupal A change from a cms to a framework would be a big step. But IMO a good one to get away from Drupal. On Aug 10, 4:39 am, Martin Westin wrote: > A bit OT, but for general interest check outhttp://openatrium.com/ > It i

having problem with redirecting. I think.

2009-08-10 Thread armen
When i remove the redirect code from the controller, the page doesn't redirect and table insertion is done correctly. but This is the message that I get when i try using redirect in the controller. ---

Email Validation in cakephp

2009-08-10 Thread arif hossen
Dear All, Please help me. Cakephp Email validation Get email address only .com .org etc But When email address enter such below: i...@a.co.uk not expect cakephp Error message appears say :not valid email address. How i can solve this email validation. -- Regards, Mohammad Arif Hossen W

lazy loading?

2009-08-10 Thread euromark (munich)
hey guys i always though cake has (like yii) some build in lazy loading feature for the models not needed (although linked in the relation arrays (HM, HABTM etc) as stated here: https://trac.cakephp.org/wiki/notes/1.1.x.x after wondering why my page got slower and slower on some views that didnt

Re: CakePHP (and other leading php frameworks) vs. Drupal custom modules

2009-08-10 Thread Martin Westin
A bit OT, but for general interest check out http://openatrium.com/ It is a "groupware"-type application written on top of Drupal. I have never used Drupal but if I was to start I would first look at how they did it. Of-course you wanted to know about going the other way... from Drupal to Cake or