Re: Testing for empty field only

2008-06-30 Thread grigri
Just add a dummy rule; if the 'allowEmpty' fails then the rule won't be checked anyway: array( 'empty' => array('allowEmpty' => false, 'rule' => '/.*/', ...), 'format' => ... ), On Jun 30, 10:27 am, marikka <[EMAIL PROTECTED]> wrote: > Hi! > > I want to be able to validate my model so that f

Re: find() puts dynamic "fields" in strange places.

2008-06-30 Thread grigri
QL logs, mainly) - it might not be too hard to provide a custom implementation of resultSet(). hth grigri --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email t

Re: Multiple ordering of a field in cake1.2

2008-06-30 Thread grigri
) )); Generates SQL: SELECT [...] FROM `cookies` AS `Cookie` WHERE 1 = 1 ORDER BY ((`Cookie`.`rating`<=1)) DESC, `Cookie`.`rating` DESC (rev. 7145) hth grigri --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups &

Re: complex findAll()

2008-06-30 Thread grigri
) )); Generates SQL: SELECT [...] FROM `cookies` AS `Cookie` WHERE 1 = 1 ORDER BY ((`Cookie`.`rating`<=1)) DESC, `Cookie`.`rating` DESC (rev. 7145) hth grigri On Jun 29, 10:49 pm, Fahad <[EMAIL PROTECTED]> wrote: > its the multiple ordering of a single field. this is what cake1

Re: prob related in input type

2008-06-26 Thread grigri
See this thread: http://groups.google.com/group/cake-php/browse_thread/thread/1ff0f7a34261a59b Will probably give you some ideas. (Why are you totally getting rid of the element, anyway?) hth grigri On Jun 26, 3:51 pm, "Jonathan Snook" <[EMAIL PROTECTED]> wrote: > Yo

Re: Daily stats (page hits) reporting with cake

2008-06-26 Thread grigri
1 DAY)) AS end_date' ), 'recursive' => 0, 'conditions' => array( 'Hit.date<>NextHit.date', '(TO_DAYS(NextHit.date)-TO_DAYS(Hit.date)>1)' ) )); // Post-process here return $data; } }

Re: Where do I find data before modification ?

2008-06-24 Thread grigri
callbacks in behaviors take the model as the first argument: function afterFind(&$model, $results, $primary) { ... } On Jun 24, 4:51 pm, Marc MENDEZ <[EMAIL PROTECTED]> wrote: > You're right : that may help you ;> > Here is it :http://bin.cakephp.org/saved/33964 > > francky06l a écrit : > > >

Re: Strange Header Error

2008-06-23 Thread grigri
think there are some automated tools to search your source files for likely culprits. hth grigri On Jun 23, 3:13 pm, killerboy <[EMAIL PROTECTED]> wrote: > Yes, I know, that something must send some stuff...but it is not my > code. > > I already searched through my project. I am a li

Re: complex findAll()

2008-06-20 Thread grigri
> Please don't do that directly. SQL (even in a limited form) sprinkled > throughout the app is never good. > > I do think that is a neat solution. However, the right way to implement > it would be to define a custom model method called 'findAllSliced()' or > something similar, so you can change t

Re: complex findAll()

2008-06-20 Thread grigri
D so they appear in that order) Then 1, 2 (again, ordered internally) hth grigri On Jun 20, 9:55 am, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote: > On Fri, Jun 20, 2008 at 2:15 PM, Fahad <[EMAIL PROTECTED]> wrote: > > findAll(), the record with ID 1 and 2 will added a

Re: UTF-8 : I don't get it !

2008-06-10 Thread grigri
The "" is a UTF-8 BOM (hex EF BB BF). Double-check your config, then make sure ALL of the files have no BOM. hth grigri On Jun 10, 3:23 pm, Pierre MARCOURT <[EMAIL PROTECTED]> wrote: > Hi, > > I have just uploaded my CakePHP project on a remote server but I meet an &

Re: Page titles that read well

2008-06-10 Thread grigri
x27;Customerproductreview'; > var $friendlyName = 'Customer Product Reviews'; > var $validate = array( > 'title' => VALID_NOT_EMPTY, > 'product' => VALID_NUMBER, > 'rating' => VALID_NUMBER, >

Re: Page titles that read well

2008-06-10 Thread grigri
s->{$this->modelClass}->friendlyName . ' - foood'); } } } Although... some might question the wisdom of setting a view-level parameter in the controller and the model. hth grigri On Jun 10, 1:37 pm, Smelly_Eddie <[EMAIL PROTECTED]> wrote: > I have always use

Re: Using Cake's core Xml class in a controller method?

2008-06-10 Thread grigri
inside correspond to the controller) * Xml's constructor detects if the string is a path or raw xml and handles it correctly so... function some_method() { App::import('Core', 'Xml'); $channel = ''; $xml = new Xml($channel); var_dump($xml); } hth grigri On

Re: Findall on a belong b belong c.name='fred'

2008-06-10 Thread grigri
Using Dardo's intuitive example: $this->Product->bindModel(array( 'belongsTo' => array( 'ParentCategory' => array( 'className' => 'Category', 'foreignKey' => false, 'conditions' => 'ParentCategory.id=Subcategory.category_id', 'fields' => array() ) ) )); $result

Re: Model->find('list') with concatenated display fields is returning an empty array

2008-06-09 Thread grigri
ot;recursive" => -1, "order" => 'name' )); // uncomment the following line to see the raw structure // The parameters to Set::combine() will make sense once you see this // debug($tmp); $projectRelationshipTypes = Set::combine($tmp, '{n}.ProjectRelations

Re: Model->find('list') with concatenated display fields is returning an empty array

2008-06-09 Thread grigri
ct) > > Method 2: Fails with the following error: > > Warning (2): vsprintf() [function.vsprintf]: Too few arguments [CORE > \cake\libs\set.php, line 357] > > On Jun 9, 1:14 pm, RichardAtHome <[EMAIL PROTECTED]> wrote: > > > Many thanks grigri :-) > >

Re: Save() triggers Mysql Insert instead of Update ...

2008-06-09 Thread grigri
Don't access the $data property directly; use the set() method: $this->MemberSearchCriteria->set('member_id', $user_id); $this->MemberSearchCriteria->save(...); Or use the $id property: $this->MemberSearchCriteria->id = $user_id; // Doesn't matter what the PK is called, always use `id` here $th

Re: Model->find('list') with concatenated display fields is returning an empty array

2008-06-09 Thread grigri
Currently, Model::find('list') only allow for simple fields to be used. Thw workaround is to use find('all') and Set::combine(). Method 1 [perform concat in SQL] : $tmp = $this->Model->find('all', array( 'fields' => array('id', 'CONCAT(name, \'/\', antonym) AS something'), 'recursive' => -1,

Re: Help me with MySQL problem

2008-06-09 Thread grigri
ySQL-specific thingy? On Jun 9, 10:46 am, Abhimanyu Grover <[EMAIL PROTECTED]> wrote: > Thanks, but it looks like a lot of work going on here, which will kill > the code simplicity unfortunately. Let me try Tarique's suggestion, > looks good by looking. > > On Jun 9, 2:31 p

Re: Help me with MySQL problem

2008-06-09 Thread grigri
> You have to use ORDER BY FIELD(id, 1, 5, 7, 4, 3) Nice! Didn't know about that. Well, you learn something new every day :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, se

Re: Help me with MySQL problem

2008-06-09 Thread grigri
method. On Jun 9, 10:31 am, grigri <[EMAIL PROTECTED]> wrote: > These are just some ideas - not sure which one would be more > efficient: > > $order = array(); > foreach ($topLinks as $linkId) { > $order[] = '(Link.id='.$linkId.') DESC';} >

Re: Help me with MySQL problem

2008-06-09 Thread grigri
7; => $order )); [or] $coef = 1; $expr = array(); for($i=count($topLinks)-1; $i>=0; --$i) { $expr[] = $coef . '* (Link.id='.$topLinks[$i].')'; } $expr = '('.implode('+', $expr) . ') AS position'; ... = $this->Link->find('all&

Re: newbie syntax question for cake 1.2 RC1

2008-06-06 Thread grigri
$this->Category->find('all', array( 'conditions' => array( 'name LIKE' => '%'.$parent.'%', 'parent_id' => null ) )); On Jun 6, 10:26 am, . <[EMAIL PROTECTED]> wrote: > Hi > > I just switched from cake 1.2.6311 to cake 1.2.7125 (RC1) > > what is the new syntax for this command? > > $th

Re: TreeBehavior and callbacks

2008-06-05 Thread grigri
> Then the children will not get deleted and I'll end up with orphans.. Really? I admit I don't use the TreeBehavior, but I am familiar with MPTT hierarchies, and I've got the code in front of me. I might well be wrong, but it seems like this: With the above code: 1. You call Asset::del(), map

Re: TreeBehavior and callbacks

2008-06-05 Thread grigri
> Unfortunately, enabling callbacks in deleteAll corrupts the tree... Yeah, that makes sense. What about deactivating the tree behavior, performing the delete, then reactivating it? function deleteAll($conditions, $cascade=true, $callbacks=true) { $this->Behaviors->detach('Tree'); $ret = par

Re: UTF8 vs Dreamweaver

2008-06-05 Thread grigri
> I use Dreamweaver as a code editor uurgh! yuck! icky icky icky! Seriously, Dreamweaver isn't meant for code editing. It's painful. Personally I use Notepad++ (the screenshots look terrible because by default all comments are in Comic Sans MS, but once you've changed that it's fine); before th

Re: question about hasOne association in 1.1

2008-06-05 Thread grigri
That's a belongsTo association. >From an English-language point of view, I can understand that it doesn't "sound" right. But it is. On Jun 5, 10:15 am, pdt <[EMAIL PROTECTED]> wrote: > Hello, > > In my real world model i would have a users that each can have one of > several available themes. >

Re: TreeBehavior and callbacks

2008-06-05 Thread grigri
Just override the Asset::deleteAll function: class Asset extends AppModel { // ... function deleteAll($conditions, $cascade=true, $callbacks=true) { // Note the default parameter change : $callbacks is now true if unspecified return parent::deleteAll($conditions, $cascade, $callbacks

Re: One app, many roles and priviledges. How?

2008-06-02 Thread grigri
> Since CakePHP 1.2 there is the possibility to define custom prefix > routing, so it can be possible to do something like: > > Router::connect('/brokers/contract/edit', array('prefix' => > 'brokers')); > Router::connect('/laywers/contract/edit', array('prefix' => > 'laywers')); > Router::connect

Re: One app, many roles and priviledges. How?

2008-06-02 Thread grigri
You might find this article interesting: http://bakery.cakephp.org/articles/view/using-cake_admin-for-multiple-user-types --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send em

Re: Multiple JOINs

2008-06-02 Thread grigri
Assuming you have set up Category belongsTo CategoryGroup, it's as easy as : (controller) $tmp = $this->Category->find('all', array( 'fields' => array('Category.id', 'Category.name', 'CategoryGroup.name'), 'recursive' => 0, 'order' => 'CategoryGroup.name ASC, Category.name ASC' )); $categor

Re: Result of a query gets messed up

2008-06-02 Thread grigri
> it might have something to do with the fact that Im using > Cake with an Oracle DB in this project... > > Perhaps in the latest Cake the problem is not known or solved for > Mysql, but still active for Oracle... Ahh, that explains much. See lines 250-251 of https://trac.cakephp.org/browser/br

Re: Result of a query gets messed up

2008-05-30 Thread grigri
I've used calulcated fields before with cake and never had this problem. What version are you using? I seem to remember on one ancient version the only way to get it to work was by starting the field with a parenthesis: $fields = array( 'Something.here', '(COMPLEX_FUNCTION(bla,blah,'woof','

Re: adding a comment after each SQL query

2008-05-30 Thread grigri
a side note, I also use geshi to syntax-hilight the sql log, also by overriding the datasource file. The two can be combined quite nicely) hth grigri On May 30, 12:31 pm, Primeminister <[EMAIL PROTECTED]> wrote: > Hi Abhimanyu, > > The thing is that I want to know it on the live en

Re: Need a lightbox type app

2008-05-30 Thread grigri
> Try shadowbox: > > http://mjijackson.com/shadowbox/ Wow, that one looks cool. And it can use mootools! > I'm hoping cake will go jQuery one day.. I'm hoping cake will go cross-framework - like shadowbox and ExtJS [though with mootools support too] --~--~-~--~~~---

Re: Convenient $html->link()

2008-05-29 Thread grigri
@jaro Sorry, I meant AppHelper(), not AppModel. Duh! AppHelper::url() is called by most helper functions that generate urls, including HtmlHelper::link(). The code is really straightforward: function url($url = null, $full = false) { if (is_array($url)) { if (isset($url['c'])) { $url

Re: hasMany with multiple foreign keys

2008-05-28 Thread grigri
[1] As you said, easy-peasy: class User extends AppModel { var $hasMany = array( 'Paper' => array('foreignKey' => 'author_id') ); } [2] It's possible, but not recommended, to do it as you suggest: class Paper extends AppModel { var $belongsTo = array( 'Author' => array('classNam

Re: hasMany with multiple foreign keys

2008-05-28 Thread grigri
class User extends AppModel { } On May 28, 2:03 pm, Robert <[EMAIL PROTECTED]> wrote: > Hi, > > I have just started playing with Cake and had some fights with > validation. Now I am at the point where I need to use hasMany on my > simple (or maybe complex) database. I am working on a web applica

Re: Convenient $html->link()

2008-05-28 Thread grigri
heh, I did this too (c/a/p shortcuts) but I put them in AppModel::url() instead. It works transparently then. On May 28, 1:29 pm, jaro <[EMAIL PROTECTED]> wrote: > Thought to share it here ... > > Extended the html helper to so that I can use shortcut keys when > creating links in cakephp views.

Re: Issue with displaying image - trailing slash on url causes issue

2008-05-20 Thread grigri
I'd have thought this would work: #header_right { background: #FFF url(read('sessionImg.'.$imgBase)); ? >) 0 0 no-repeat; } --~--~-~--~~~---~--~~ You received this message because you are subscr

Re: Finding popular activities

2008-05-20 Thread grigri
$this->Activity->bindModel(array( 'hasOne' => array( 'TotalUsers' => array( 'className' => 'User', 'fields' => 'COUNT(TotalUsers.id) AS num_users' ) ) ); $popularActivities = $this->Activity->find('all', array( 'conditions' => '1=1 GROUP BY Activity.id HAVING num_users >

Re: UNION CakePHP/MySQL

2008-05-19 Thread grigri
> One thing, though. The $order ('duedate ASC') shouldn't be necessary, > as you're selecting on just a single date. Well spotted! That's very true - it's a bit like saying "pick all the blue M&Ms and arrange them by colour". I wasn't paying attention to that bit... --~--~-~--~~--

Re: Data validation problem

2008-05-16 Thread grigri
$this->Post->create($this->data); if ($this->Post->validates()) { // Data is good } else { // Data contains errors } On May 15, 9:21 pm, Wojtek <[EMAIL PROTECTED]> wrote: > I have a problem with validating data without saveing anything in > database. > For example this script work good > if

Re: Associations with 4 tables and 2 models ?

2008-05-16 Thread grigri
Three things come to mind: * Model names are singular in cakephp, not plural. [see manual] * If you set the recursive variable higher, you should get the rights [see manual] * why are you declaring all that fluff you don't need? class User extends AppModel { var $hasAndBelongsToMany = array(

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
> I am using 1.1 and your last code works just fine !!! > Thank you very much, it is just what I needed ! Glad I could help. Do you understand *why* it works? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP"

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
k`. FROM `tasks` AS `Task` LEFT JOIN > `users` AS `User` ON (`Task`.`user' at line 1 in > *Z:\dev\frameworks\cake\cake\libs\model\datasources\dbo_source.php* on > line *440* > > I try by changing your code regarding to the error but I still get a SQL > Error... > > &g

Re: Form posting with type=get

2008-05-16 Thread grigri
> If you are not using Cake to process the form why use FormHelper when > a good old hand-coded form in HTML works. > > To me Helpers are great time savers when you are utilizing the > frameworks features: validations, auto read/write values to view, > posting to the next action in your controller

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
> That's why I was wondering if there is a way to do it better. > > I think that your example is better than mine because you are doing a > simple query ($tmp) to get the ids (this query should not take too long) > and then the /findAll()/ query. > I don't like my way becau

Re: problem with findAll

2008-05-16 Thread grigri
Try this: $free_applications = $this->Candidate->JobApplication->findAll(array( "Candidate.id" => $id, "JobApplication.status" => 1, "JobApplication.recruitment_id" => "!= IS NOT NULL" )); On May 16, 9:12 am, flo35 <[EMAIL PROTECTED]> wrote: > Hi > i have a problem with FindAll. I want fie

Re: UNION CakePHP/MySQL

2008-05-16 Thread grigri
>findAll(array('Product.id' => $ids)); hth grigri On May 16, 2:17 pm, Pierre MARCOURT <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to make a MySQL request with an UNION but I can't find out > a way to do it by using CakePHP methods. > I looked at Google

Re: Paginator and subdirectory

2008-05-16 Thread grigri
> There's not much to show. All I want to do is prepend '/membership/' > to all members routes. this works fine for me: -- routes.php -- Router::connect('/membership/members/:action/*', array('controller' => 'members')); Nothing special at all in the controller or view. Works with scaffold, wor

Re: Associations and queries using 2 models

2008-05-16 Thread grigri
> Video hasMany AlbumVideo; AlbumVideo hasMany Albums. This implies that Album belongsTo AlbumVideo and AlbumVideo belongsTo Video; i.e: Video : [id, ...] AlbumVideo: [id, video_id, ...] Album: [id, album_video_id, ...] > Now I would like to search in Album and song title. You're not being cle

Re: is there a way to know if I'm updating or creating a record inside beforeSave() ?

2008-05-15 Thread grigri
> - If $this->id (in model's beforeSave() callback) is false then you are > creating record otherwise it has id of record which will be getting updated Although generally true, this is not always the case. If you specify the primary key, but that record does not exist, it will be an insert, but t

Re: is there a way to know if I'm updating or creating a record inside beforeSave() ?

2008-05-15 Thread grigri
> I'm wondering if there is any way that I can know if I'm updating or > deleting when I'm inside the beforeSave function Assuming you meant "updating or creating"... function beforeSave() { if ($this->exists()) { // It's an update } else { // It's a create } } --~--~-~-

Re: findAll HAVING

2008-05-13 Thread grigri
ursive' => 0, 'fields' => 'Author.*, COUNT(Post.id) AS num_posts', 'conditions' => '1=1 GROUP BY Author.id HAVING num_posts>5', 'order' => 'num_posts DESC' )) hth grigri On May 13, 9:47 am, David <[EMAIL PROTECTE

Re: Use model inside helper

2008-05-13 Thread grigri
> Only it works for some model and for other it doesn't work. > Why? It will only work for models that are already loaded and registered. If you need a model that hasn't been loaded, you'll have to use App::import() to load it first. --~--~-~--~~~---~--~~ You rece

Re: Query Question

2008-05-12 Thread grigri
// Controller $parks = $this->Skatepark->find('list', array( 'fields' => array( 'Skatepark.id', // Key path 'Skatepark.city', // Value path 'Skatepark.state' // Group path ), 'order' => 'Skatepark.city ASC, Skatepark.state ASC' ); $this->set(compact('parks')); // parks looks lik

Re: Find Parent By Child

2008-05-09 Thread grigri
Try this: http://groups.google.com/group/cake-php/browse_thread/thread/863305f8a7267067 On May 9, 4:14 pm, thewebguy <[EMAIL PROTECTED]> wrote: > I'm having trouble with a findAll() query. I may not fully understand > how associations work, so I'm here for help. > > So I've got 3 classes: > > Cl

Re: Label with checkbox formhelper and CakePHP 1.2

2008-05-09 Thread grigri
> What field type creates a checkbox? I was looking for this earlier > and was unable to find it. boolean type (on MySQL, TINYINT(1) is also classed as a boolean and gets a checkbox. Not sure about other database systems). --~--~-~--~~~---~--~~ You received this

Re: Label with checkbox formhelper and CakePHP 1.2

2008-05-08 Thread grigri
The form helper's `input()` and `inputs()` methods generate labels, the individual control methods (`text()`, `checkbox()`) do not. This is 100% by design. > So.. how do i manage to properly label the checkbox? echo $form->input('dbDBName',array( 'label' => _('DB Database Name', 'type' => 'check

Re: find('all') combine problem

2008-05-08 Thread grigri
Here ya go: $teams = $this->Team->find('all', array( 'fields' => array('id', 'firstName', 'lastName'), 'recursive' => -1 )); $result = Set::combine( $teams, '{n}.Team.id', array('%s %s', '{n}.Team.firstName', '{n}.Team.lastName') ); See http://groups.google.com/group/cake-php/browse_t

Re: no scripts on home page?

2008-05-02 Thread grigri
heh - depends on my caffeine intake, I suppose On May 2, 3:29 pm, Sliv <[EMAIL PROTECTED]> wrote: > which one of us is the "evil" twin... :P --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to

Re: Use model inside helper

2008-05-02 Thread grigri
> In a word, no. Controller sends the data prepared by your model to the > view where your helper can access it. Hmm... I'd have to disagree there. With regards to data [the four horsemen CRUD], I totally agree - you should not do this in a helper. On the other hand, model/schema inspection is

Re: no scripts on home page?

2008-05-02 Thread grigri
There's nothing 'special' about the PagesController - it uses the 'Html' helper unless you tell it not to. Without seeing some code, it's impossible to be certain... ...but, were I a gamber, I'd bet that you're doing this: link(...); ?> instead of this (which works): link(...); ?> If this is

Re: coding standards & saving serialized data to the db

2008-05-02 Thread grigri
n in afterFind(), so it makes it difficult. I'd just like to say 'before you save, these values get serialized into this field' and 'after retrieval, this field gets unserialized into those values', and have it happen automagically. It's possible a behavior could be wr

Re: Formatting Forms

2008-05-02 Thread grigri
$defaults = array( 'before' => '', 'between' => '', 'after' => '', 'div' => false // Don't forget this ); $inputs = array( 'fieldset' => false, // Don't forget this 'eggs' => array_merge($defaults, array('type' => 'text', 'value' => 'test')), 'bacon' => array_merge($defaults, array('

Re: coding standards & saving serialized data to the db

2008-05-02 Thread grigri
I was going for this approach on a project a while ago... didn't do it in the end though. I'm sure that it's always possible to avoid having to do this, but in some cases it might be well worth it. There doesn't seem to be an easy, well-documented way of handling this sort of thing. I mean, wher

Re: problems with bake

2008-04-30 Thread grigri
Sounds like your php dir is not in your PATH. On Apr 30, 3:27 pm, chuck24 <[EMAIL PROTECTED]> wrote: > I set up the console as the screen cast suggested. I also am using > wamp so that so that eased things a bit. I also adjusted the path to > meet my file locations. I am still however getting the

Re: Controller methods that don't lead to a view

2008-04-30 Thread grigri
> Right, so I need to prefix the function call with $this-> > > Why exactly???!!! That's how PHP works. "Don't forget that in CakePHP, there's still PHP" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" gro

Re: Additional information about association in the HABTM table

2008-04-30 Thread grigri
For retrieval, this is easy: just add the extra columns to the join table; you can optionally create a model file for the join if you need to. Do a debug() on the fetched data array and you'll see all the extra fields in there. It's putting the extra data in there easily that's more complicated -

Re: FindAll field condition

2008-04-30 Thread grigri
> If I express the last condition like: > > 'Post.datetime1' => '>Post.datetime2' > > I get anything > How can I do this? Seriously man, "I get anything"? Not much to go on - try pasting the SQL that's being generated. Well, next time anyway. You just need to use the "just trust me on this" oper

Re: trouble reading data from array

2008-04-30 Thread grigri
This isn't a cake issue, it's just basic PHP string/variable parsing Either: '/questions/add/' . $this->data['Survey']['id'] or "/questions/add/{$this->data['Survey']['id']}" or, even better array('controller' => 'questions', 'action' => 'add', $this- >data['Survey']['id']) [slightly more v

Re: Controller methods that don't lead to a view

2008-04-30 Thread grigri
Just prefix your internal controller methods with an underscore. Then they won't be accessible as actions. class SomeController extends AppController { function do_something() { // this is an action $foo = $this->_do_something_internally(); } function _do_something_internally() {

Re: Mass edit in CakePHP?

2008-04-29 Thread grigri
$this->YourModel->updateAll(array('new_field' => 'new_value'), array('1=1')); Note that you'll have to quote/escape the value yourself. On Apr 29, 4:27 pm, SumanRS <[EMAIL PROTECTED]> wrote: > Hi, > > I've been using CakePHP for creating an online version of a listing > that has long been mainta

Re: Conditions for multiple tables

2008-04-29 Thread grigri
I do it like this : http://groups.google.com/group/cake-php/browse_thread/thread/863305f8a7267067 it works fine, even with lots of associated models. Doing `and` joins (series must have genre 'bacon' AND genre 'eggs') is more longwinded because you have to perform a separate join for each one, b

Re: update just one field

2008-04-29 Thread grigri
Try Model::saveField() http://api.cakephp.org/1.2/class_model.html On Apr 29, 1:23 pm, JoC <[EMAIL PROTECTED]> wrote: > Hello, > I am having a problem with saving just one field. > I baked my MVC for my user table and everything went fine > THen i went to the controller and created a new functin

Re: Can Cake Do Calculated Ordered List SQL Queries?

2008-04-25 Thread grigri
' => 'health', 'limit' => 10 )); The one 'gotcha' is that the result won't be where you might expect in the returned data. Calculated fields have no associated table, so as far as cake can see; they belong to no model. So your returned data array w

Re: Elementary Data Validation??

2008-04-25 Thread grigri
=> '', 'after' => ''), 'Customer.firstname'=> array('size' => 30), 'Customer.surname' => array('size' => 30), 'Customer.tos' => array('div'=>true, '

Re: MySQL Views support in Cake 1.2

2008-04-25 Thread grigri
I know nothing about using MySQL views, but I've never found it a problem to filter/sort on deep associations. The trick is to use dynamic associations - a temporary `hasOne` instead of a `hasMany`, so that cakephp performs a join and you can then filter inline in the query. For example, let's a

Re: extra number character in Flash message

2008-04-24 Thread grigri
You're using echo to display the session flash. Remove the echo call and you'll be fine. (btw, this is listed on the FAQ page) On Apr 24, 3:09 pm, Zoltan <[EMAIL PROTECTED]> wrote: > I'm doing this bit that resets the user's password that set-up a flash > message using: > > $this->Session->setFl

Re: difference between saving in add and edit

2008-04-24 Thread grigri
> The create function will look for an id passed in the $this->data for > the model. If it sees one, it understands the save should perform an > update, if there is no id, it understands the save as an insert. That should be 'if it sees one, and a record with that PK exists, it understands the sa

Re: Multiple foreign keys to the same table.

2008-04-24 Thread grigri
class Answer extends AppModel { var $belongsTo = array( 'PrevQuestion' => array('className' => 'Question'), 'NextQuestion' => array('className' => 'Question'), ); } This will imply the foreign keys being 'prev_question_id' and 'next_question_id'; you can set the foreignKey entry in the

Re: Router::queryString issue in 1.2 beta

2008-04-24 Thread grigri
> 1) http_build_query is a PHP5-only function It's implemented for PHP4 in basics.php, along with array_intersect_key, array_diff_key, file_put_contents and array_combine. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou

Re: How to use "not in" in new find() ?

2008-04-22 Thread grigri
Try: $this->Model->find('list', array('fields' => array('id', 'name'), 'conditions' => array('not' => array('id' => $model_ids; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this gr

Re: cake and JS question

2008-04-22 Thread grigri
is will help code editors to syntax hilight properly and generally not get confused.) Escaping the string to a html-and-javascript--friendly format might be required though. Hope this helps grigri On Apr 22, 10:15 am, . <[EMAIL PROTECTED]> wrote: > in cake 1,2 How do you add a javascript funct

Re: Is there any function to escape strings ?

2008-04-21 Thread grigri
cake provides a global shortcut function called h() which internally calls htmlspecialchars() with the charset defined in your config. There's no actual helper method for this. data['Some']['thing']); ?> On Apr 21, 1:34 pm, Neveldo <[EMAIL PROTECTED]> wrote: > Hi all, > > I would like to escape

Re: Turning off automatic escaping

2008-04-21 Thread grigri
> I want to save the characters '<' and '>' into the database but I > believe cake's automatic parsing is converting the html entities to > < and > I seriously doubt this is true - I've never seen this behaviour. Sure, if you're sanitizing the input then they might get escaped [depending on your

Re: How to view all Cake queries?

2008-04-21 Thread grigri
Put it in this folder: /app/models/datasources/dbo/dbo_mysql_ex.php And in /app/config/database.php you need to specify 'driver' => 'mysql_ex' in the connections On Apr 18, 10:12 pm, "R. Rajesh Jeba Anbiah" <[EMAIL PROTECTED]> wrote: > On Apr 18,

Re: How to view all Cake queries?

2008-04-18 Thread grigri
this helps grigri On Apr 18, 3:59 pm, Corie <[EMAIL PROTECTED]> wrote: > Of course I have debug set to 2, but sometimes redirects are used. > > I'm specifically trying to troubleshoot an Auth problem and need to > see the queries g

Re: How to prevent escaping of numbers for ORDER BY?

2008-04-18 Thread grigri
Try adding it as a field in your find, then sorting by the field alias: SELECT [...], ((thread.views*0.1)+*(thread.messages*0.8)) AS something FROM [...] ORDER BY something DESC On Apr 18, 7:28 am, hks <[EMAIL PROTECTED]> wrote: > In my query, I want to use 'order' => "( (thread.views * 0.1) +

Re: (n00b) Issue setting layout

2008-04-17 Thread grigri
If you really need to change the layout per-page, then extending the page_controller is the way to go. There's a bakery article on this subject [http://bakery.cakephp.org/articles/view/taking-advantage-of- the-pages-controller] Basically, if you have a page called 'faq' then the pages controller

Re: can i use a component under a helper?

2008-04-17 Thread grigri
ght well be overkill if you don't really need specific component/helper logic - just put it in a vendor class and go. hth grigri On Apr 17, 10:24 am, dbruensicke <[EMAIL PROTECTED]> wrote: > I have seen a lot of components which use serialized data in sessions > to interc

Re: Problem with autocomplete in IE

2008-04-17 Thread grigri
I don't know if it's relevant, but try adding this javascript to the relevant page: try { document.execCommand("BackgroundImageCache", false, true); } catch(err) {} [put it in an ie cc - nothing else needs it] On Apr 17, 11:12 am, lekshmi <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using cak

Re: newbie how to update a row with 2 primary keys

2008-04-17 Thread grigri
"id". Well, you don't have to call it "id". Just set the `$primaryKey` member variable (in the model) to the name of the primary key. hth grigri --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

Re: Form Helper Issue

2008-04-16 Thread grigri
Read : http://book.cakephp.org/view/85/saving-related-model-data-habt It describes the proper way to create a habtm form and save the related data [especially the last sentence!]. Also, I'm not sure I understand about the multiple-select-box. You've defined an assoiciation where `A` has and belo

Re: single view for multiple controllers

2008-04-16 Thread grigri
function viewx() { $this->set('students', ...); $this->render('viewall'); } On Apr 16, 6:52 am, damo <[EMAIL PROTECTED]> wrote: > Can't seem to figure this one out. > > I have two controllers that I would like to use the same view for. > Here is how they are: > > function viewall() >

Re: Page specific javascript

2008-04-15 Thread grigri
> That would seem to me like a bit of a sledgehammer solution. Perhaps I misinterpreted. If you just want 'register.js' to appear on the 'register.ctp' view, then indeed you should just do it in the view. I thought the OP wanted a generic automagic solution for including javascript files based on

Re: weird behaviour of query conditions

2008-04-15 Thread grigri
Is this related to https://trac.cakephp.org/changeset/6641 ? If the changeset didn't fix the problem, you should re-open the ticket [4349] with a test case. On Apr 15, 12:36 pm, bingo <[EMAIL PROTECTED]> wrote: > oops... > > actually both the strings are same..I accidentally placed a > comma...t

Re: Different pagination condition for different functions

2008-04-15 Thread grigri
ginate = $this->paginateEx[$this->action]; } else { $this->paginate = $this->paginateEx['default']; } } } hth grigri On Apr 15, 5:19 am, aj <[EMAIL PROTECTED]> wrote: > Hello, > > I want to have different pagination conditions for different

<    1   2   3   4   5   6   >