Re: How to specify a count(id) field for find method

2011-08-16 Thread Roland Pish
Wow! I could do it with a virtual field. Thanks gremlin! On 15 ago, 23:14, gremlin wrote: > Or use a virtual field. > > On Aug 15, 11:44 am, Roland Pish wrote: > > > > > > > > > Thanks Jeremy. > > I looked at the cookbook with the link you provided a

Re: How to specify a count(id) field for find method

2011-08-15 Thread Roland Pish
array('Product.type','MIN(Product.price) as > price'), 'group' => 'Product.type'); > > Jeremy Burns > Class Outfit > > http://www.classoutfit.com > > On 14 Aug 2011, at 22:54, Roland Pish wrote: > > > > > > >

Re: How to specify a count(id) field for find method

2011-08-14 Thread Roland Pish
Thanks for your reply euromark. I tried the find->('count' but it just returns a number, not the records grouped by 'status' field. On 14 ago, 15:09, euromark wrote: > $this->Member->find('count', ...) > it should be in the cookbook, the documenta

How to specify a count(id) field for find method

2011-08-14 Thread Roland Pish
Hello. I need to issue a query like: select count(id) as total,status from members group by status When specifying the fields for the model find method I do this: $fields = array('count(Member.id) as total','Member.status'); $members = $this->Member->find('all',array('fields'=> $fields,'group'=>

Re: Custom controller name

2011-07-30 Thread Roland Pish
=> 'cals', >         'action' => 'index')); > > but you can have the model useTable an 'some_unconventional_name' > with the following in the model >     public $useTable = 'cal'; > >  - S > > On 30 July 2011 23:43, Roland

Custom controller name

2011-07-30 Thread Roland Pish
I have a model named "Cal". I wanted its table name to "cal" (not "cals"). Now, I would like that its controller could be accessed as: mysite.com/ cal/* (and avoid being accessed as mysite.com/cals/*). A plus would be that I can declare the controller as: class CalController extends... Is this

Question about pagination

2011-05-01 Thread Roland Pish
Hi there. When displaying $paginator->numbers(), I need to replace the current class of the current page from 'current' to 'active', so that the current page instead of displaying: ... I want it to display: ... I've researched in $paginator->numbers() options but I haven't found a way to change t

Re: $this->Session->valid() strangely returning false

2011-03-29 Thread Roland Pish
: > > if($this->Session->check('somvar') == true) { >  // Session exists} else { > >  // Session does not exist > > } > > On 27 March 2011 19:09, Roland Pish wrote: > > > > > > > > > > > Hello there. > > > I have

$this->Session->valid() strangely returning false

2011-03-27 Thread Roland Pish
Hello there. I have this code: $this->Session->write('somevar',array(1,6)); // Creating somevar test session variable debug($this->Session->read()); // Dumping session contents. NOTE: this displays correctly the contents of "somevar" if ($this->Session->valid()) { debug('Session is valid'); }

HABTM find question

2010-12-13 Thread Roland Pish
Hi, I have two models: Member and Department which HABTM each other. I'm doing the following find: $this->Member->Department- >find('all',array('conditions'=>array('Department.name LIKE'=>'%'. $somesearchvalue.'%'))); This gives me a resulting array where each position has the Department data pl

Question about ACL

2010-09-03 Thread Roland Pish
Hi there. I'm starting with a project which will need the use of ACL to control permissions. These are the tables involved in permissions: Users (a user always will belong to a group) Groups Operations Permissions will be established only between Groups and Operations like: Group 1 are granted

How to involve two databases in a single sql query?

2010-08-12 Thread Roland Pish
Hi. I'm developing a project which needs to access two databases in a single sql query (or in a single Find call), so my question is if in cakephp is possible to perform a Find like: select * from `database1`.`table` where `database1`.`table`.`id` in (select id from `database2`.`table`) Thanks i

Re: Validation errors not shown in a form

2010-07-30 Thread Roland Pish
know then. Thanks! On 30 jul, 04:13, Marco wrote: > Are you sure you are using the $form->input for all the fields and > $form->create? > > On Jul 30, 2:19 am, Norman Paniagua wrote: > > > Can you show your code? > > --- > > > Norman Paniagua > > &

Validation errors not shown in a form

2010-07-29 Thread Roland Pish
Hi. Suddenly a form stopped showing the error messages with the beside input fields with validation. When a validation error occurs. If I debug($this->Themodel- >validationErrors) it shows me the errors but there is no anymore. What could be wrong? I don't remember changing anything in cake's

Re: Question about slugs

2010-07-15 Thread Roland Pish
t; /user/miles > /team/lakers > /band/u2 > > Etc. > > On Jul 14, 4:23 pm, Roland Pish wrote: > > > Thanks a lot Sam. Great idea. > > I'll add the routes for the other controllers. > > > Regards. > > > On 14 jul, 16:33, Sam wrote: > > >

Re: Question about slugs

2010-07-14 Thread Roland Pish
ontroller'=>'example', > 'action' => 'index')); > > Or, you could modify your slugs routing and add a path before the slug > e.g. > > Router::connect('example/:slug/ > *',array('controller'=>'practitioners','a

Question about slugs

2010-07-14 Thread Roland Pish
Hi. I have urls like this in my project: www.mysite.com/practitioners/view/1 and I want to convert them to: www.mysite.com/the-name-of-the-practitioner So I started using slugs (and the corresponding db field) and configured this: Router::connect('/:slug/ *',array('controller'=>'practitioners'

Re: Can I read a session variable inside the model?

2010-06-29 Thread Roland Pish
late $session['User']; > >   return something; > > } > > > --- Controller --- > > function viewSomething() { > >    $this->ModelName->whatEver($this->Auth->user()); > > } > > > On Jun 29, 5:59 pm, Roland Pish wrote: > > > Hi!

Can I read a session variable inside the model?

2010-06-29 Thread Roland Pish
Hi! I would like to know if I can read a session variable in the model, I tried with: $this->Session->read... and with Session::read... but none of them work. Thanks in advance. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You

Re: HABTM find question

2010-06-18 Thread Roland Pish
akePHP book, > see:http://book.cakephp.org/view/1039/Associations-Linking-Models-Togethe... > > The last example is the one. Maybe it can be applied to your issue :) > Enjoy, >    John > > On Jun 18, 6:40 am, Roland Pish wrote: > > > Hi! > > I've been struggling with

HABTM find question

2010-06-17 Thread Roland Pish
Hi! I've been struggling with something that I cannot seem to get working. I have this relationship: Treatment HABTM Symptom What I want to do is: search treatments by symptom, and the result must display treatments fields (id, name, cost, etc). For now, I've been doing this in treatments_contro

Get rid of render time in ajax response

2010-06-10 Thread Roland Pish
Hi! I'm doing some ajax calls and I realized that cakephp is appending the render time to the ajax response; something like: I set debug to 2 because I'm in the development phase. I assume that setting debug to 0 gets rid of the render time, but, keeping the debug set to 2 is there some way to ge

Strange error after model save method

2010-06-07 Thread Roland Pish
Hello. I was creating an "add" form for a model called Practitioner. Everything seems to work fine, after submitting the form changes are saved successfully in Practitioner table and in every table related to Practitioner model, but a weird error is showing up that's claiming for a "rght" field in

Re: Validation from controller question.

2010-06-03 Thread Roland Pish
Sorry for the noise. I found what I was doing wrong. I was calling the Model->validates() before tweaking another fields data (whose errors were shown up). Now I call the Model->validates() immediately before the Model->save() and now it's working as expected. Cheers. On 3 jun,

Validation from controller question.

2010-06-03 Thread Roland Pish
Hello. I need to do this validation in a field in a controller: $this->Model->set($this->data); if ($this->Model->validates(array('fieldList' => array('some_field' { // code to create other fields and send an email } Then (as it nothing happened above) I call $this->Model->save($this- >dat

Re: One to Many question

2010-06-02 Thread Roland Pish
Ok, got it. I'll go for this containable behaviour right now. Thanks for you replies guys. Regards On 2 jun, 23:03, Roland Pish wrote: > Thanks Graham! > > So, this conditions array is mandatory in find method right? > > Regards > > On 2 jun, 23:01, Roland Pish wr

Re: One to Many question

2010-06-02 Thread Roland Pish
Thanks Graham! So, this conditions array is mandatory in find method right? Regards On 2 jun, 23:01, Roland Pish wrote: > Thanks for your reply Jeremy. > > I was avoiding the conditions array because I thought cake would do > the "magic" and the automatic filter. > I

Re: One to Many question

2010-06-02 Thread Roland Pish
rote: > I'd try this: > > > $foreignSchools = $this->Student->ForeignSchool->find('all', > > array('conditions' => array('ForeignSchool.student_id' => 2))); > > (hope the number of brackets is right...) > > Jeremy Bur

One to Many question

2010-06-02 Thread Roland Pish
Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany

Re: HABTM Question.

2010-05-28 Thread Roland Pish
dard thing. But here's a page > that refers specifically to HABTM: > > http://book.cakephp.org/view/1390/Automagic-Form-Elements > > Jeremy Burns > jeremybu...@me.com > > On 29 May 2010, at 06:10, Roland Pish wrote: > > > It worked!! > > Finally!!

Re: HABTM Question.

2010-05-28 Thread Roland Pish
$funnyTags)? Best regards. On 28 mayo, 22:57, Roland Pish wrote: > Thanks, We are getting closer!! > > After using $funnyTags now the select is populated correctly but the > funny tags aren't selected according to what is on the database. > > I tried this: echo $form->input(

Re: HABTM Question.

2010-05-28 Thread Roland Pish
51, Jeremy Burns wrote: > Ah. Try this: > > $funnyTags = > $this->Post->FunnyTag->find('list',array('fields'=>array('id','name'))); > > If that doesn't fix it, try this as well: > > echo $form->input('FunnyTag&#

Re: HABTM Question.

2010-05-28 Thread Roland Pish
ag- >find('list',array('fields'=>array('id','name'))); $this->set(compact('funny_tags')); } } Contents of form.ctp: create('Post',array('url'=>array('action'=>'form')));?>

Re: HABTM Question.

2010-05-28 Thread Roland Pish
#x27;name'))); > > ...and change this: > $this->set(compact('tags')); > > ...to this: > $this->set(compact('funny_tags')); > > Does that resolve it? > > Jeremy Burns > jeremybu...@me.com > > On 29 May 2010, at 04:20, Roland Pish wrot

HABTM Question.

2010-05-28 Thread Roland Pish
Hi! I've been struggling for a long time with something and I don't seem to get it. I did the Posts/Tags HABTM Select example from this page: http://mrphp.com.au/code/working-habtm-form-data-cakephp So far so good, everything works ok. I wanted to try the same example but asumming that the table

Re: Join table question

2010-05-28 Thread Roland Pish
hp.org/view/1044/hasAndBelongsToMany-HABTM > > Jeremy Burns > jeremybu...@me.com > > On 26 May 2010, at 22:21, Roland Pish wrote: > > > Hello. > > I have two tables with a many-to-many relationship between them: > > practitioners and practi

Join table question

2010-05-26 Thread Roland Pish
Hello. I have two tables with a many-to-many relationship between them: practitioners and practice_areas. So, the join table name should be: practice_areas_practitioners? Is this correct according to cakephp conventions? Is more than one underscore allowed for a join table name? I'm afraid that I