Re: weird problem with paginator (Cake 1.3)

2009-12-23 Thread Ernesto
hi mark thx for the reply.

you said
Well since you can't join across connections, that kind of makes
sense
doesn't it?

so why the page is loading ok the first time, when there's no
paginator options in url? this problem occurs only when i try to sort
by Customer.name
obviously there isn''t any db-level link between customers and orders
tables because they're in different DBs but cake should map there
tabs anyway...

the thing that doesn't makes sense to me is:
- the data (even Customer.name) is loaded and showed correctly so this
field is present in data array but...
- paginator can't find (and sort) it...

In any case I highly doubt your issue is specific to 1.3,
or even 1.2 and has much more to do with attempting to set order
clauses on tables that are not part of your pagination query.  Check
your query to make sure all the required tables are in one query.

yes that's the problem. Paginator doesn't load my table even if the
relationship is correctly defined in contain subarray and
containable is loaded.

sry for my very bad eng.

-Ernesto

On 22 Dic, 15:11, mark_story mark.st...@gmail.com wrote:
 Well since you can't join across connections, that kind of makes sense
 doesn't it? In any case I highly doubt your issue is specific to 1.3,
 or even 1.2 and has much more to do with attempting to set order
 clauses on tables that are not part of your pagination query.  Check
 your query to make sure all the required tables are in one query.

 -Mark

 On Dec 22, 5:37 am, Ernesto e.fanz...@gmail.com wrote:



  it looks like Paginator in 1.3 has a bug - he's ignoring the models
  using different DB connection

  can anyone confirm this?

  On 21 Dic, 17:08, Ernesto e.fanz...@gmail.com wrote:

   hello.

   my webapp has 3 models:

   Order, Item and Customer

   Order belongsTo Item
   Order belongsTo Customer

   both OrderModel and ItemModel are in app's models dir.
   CustomerModel is located in an external dir, defined in
   bootstrap.php's app build

   here's a piece of my OrdersController

   class OrdersController extends AppController {
      [...]
      var $paginate = array(
         limit = 20,
         contain = array(
            Item,
            Customer
         ),
         order = Order.Code
      )

      function index() {
         $this-set(orders, $this-paginate(Order));
      }

   }

   and here's a piece of my Orders index

   [...]
   th?php echo $paginator-sort(Order code, Order.code) ?/th
   th?php echo $paginator-sort(Customer, Customer.name) ?/th
   [...]

   if i click on Order code the page will work correctly and data will
   be displayed sorted by Order.Code
   if i click on Customer the page will return an error like SQL
   Error: 1054: Unknown column 'Customer.name' in 'order clause'

   i can't figure out the reason of this error...

   CustomerModel and CustomersController are working ok. i can insert/
   update/delete without errors.

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


MySQL queries optimizations FORCE INDEX on bindModel

2009-12-23 Thread Emanuel Nedelcu
Hello,

Is there any way I can force the use of an index using the bindModel?
On normal MySQL queries I can do something like this  INNER JOIN
table FORCE INDEX (table.index) ON .
Does bindModel supports something like this?

Thank you!

Emanuel

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


Issue with timeAgoInWords() method

2009-12-23 Thread Mario
Hi all,

I have a probelem with the 'userOffset' option of
http://api.cakephp.org/class/time-helper#method-TimeHelpertimeAgoInWords

This snippet of test code in view
?php
echo $activity['Activity']['modified'];

echo $time-timeAgoInWords(
$activity['Activity']['modified'],
array('userOffset' = 5)
);

echo $time-timeAgoInWords(
$activity['Activity']['modified'],
array('userOffset' = 4)
);
?

outputs something like:

2009-12-23 10:59:30
7 hours, 4 minutes ago
7 hours, 4 minutes ago

meaning that no matter what the userOffset option contains, no offset
seems to be applied, I would have expected a 1 hour difference in
between the two outputs.

Any hint or suggestion?

Best,

Mario

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


Merging objects

2009-12-23 Thread ashok.b
Hi, this is not exactly a cakephp query, but a query with php in
general i suppose.

I'm looking to insert a random quote at the end of every blog post.
Quotes come from a quotes table and blog posts comes from posts table.

I created a function in QuotesController which outputs a randomly
selected row from the quotes table. Output array:
Array
(
[0] = Array
(
[sitecaptions] = Array
(
[id] = 2
[caption] = Great camera deals!
[linkurl] = http://www.99hotdeals.com/cat/Cameras
and Camcorders
)

)

)

The PostsController function output:
Array
(
[0] = Array
(
[Post] = Array
(
[id] = 2797
[post_title] = xx1
[item_desc] = xx desc
[dateadded] = 2009-12-22 11:10:15
)
[Category] = Array
(
[0] = Array
(
[id] = 99
[name] = Others
)

)
   )
[1] = Array
(
[Post] = Array
(
[id] = 2798
[post_title] = xx2
[item_desc] = xx2 desc
[dateadded] = 2009-12-22 11:10:45
)
[Category] = Array
(
[0] = Array
(
[id] = 99
[name] = Others
)

)
   )
)

As you can see, the Posts Object contains two elements, [Post] and
[Category] for each record [0],[1] etc. I want to insert the
[sitecaptions] element into that Posts Object so that in effect it
looks like:
Array
(
[0] = Array
(
[Post] = Array
(
[id] = 2797
[post_title] = xx1
[item_desc] = xx desc
[dateadded] = 2009-12-22 11:10:15
)
[Category] = Array
(
[0] = Array
(
[id] = 99
[name] = Others
)

)
[sitecaptions] = Array
(
[id] = 2
[caption] = Great camera deals!
[linkurl] = http://www.99hotdeals.com/cat/Cameras
and Camcorders
)
   )
)

How do I combine two objects like that? Or how do I insert elements
into an existing object? Hope I'm clear about what I'm asking. Thanks
for your time...

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: Naming Conventions

2009-12-23 Thread John Andersen
Hi Dave,

Your tables should be in plural - profiles_skills - to conform to
CakePHP conventions :)

Enjoy,
   John

On Dec 23, 3:44 am, Dave make.cake.b...@gmail.com wrote:
 Following the logic pointed out by AD7six in the reply below my message, I
 end up with missing table.

 I created my models as:
 Profile
 Skill
 ProfileSkill

 Database has:
 profiles
 skills
 profile_skills

 Database table profile_skill for model ProfileSkill was not found.

 Where did I go wrong here?

 Thanks guys

 Dave

 -Original Message-
 From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf

 Of AD7six
 Sent: December-22-09 5:42 AM
 To: CakePHP
 Subject: Re: 3 Days and not 1 person has any idea?

 On 21 dic, 22:05, Dave make.cake.b...@gmail.com wrote:
  Thanks John,

  That’s correct what I am trying to do as you stated.

  HABTM Structure
  Profile
          id

  Skill
          id
          name

  profile_skill
          profile_id
          skill_id
          year - this is my new aded field

 IMO your whole problem stems from trying to refer to a model as a join
 table. When a join table has more than 2 fields - make it a model. If you
 give profile_skill a primary key, create a model for it, define Profile
 hasMany ProfileSkill etc. you've find your difficulties pretty much
 dissolve.

 hth,

 AD

 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.com For more options, visit this group
 cake-php+athttp://groups.google.com/group/cake-php?hl=en
 No virus found in this incoming message.
 Checked by AVG -www.avg.com
 Version: 9.0.717 / Virus Database: 270.14.114/2575 - Release Date: 12/21/09
 15:43:00

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


Adaptive pagination

2009-12-23 Thread NeoWebTech
Hello!

I want to create a pagination for a huge/large number of items. But,
the default pagination component is not good when the number of pages
increases. So, I want to display like the following

« Previous 1 2 … 5 6 7 8 9 10 11 12 13 … 2789 2790 Next »

Please, let me know if there is any plug-in/code available.

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


Help With model Idea Setup

2009-12-23 Thread Dave
I have played with this idea as many have seen me post over the past few
days and since nothing is going as planned I have decided to start the idea
from scratch and would like some feedback on how you would do it.
 
I simply wanted to add an additional field to my join table of profile and
skills, profile HABTM skills so i have given up on that since that came to a
very disappointing conclusion.
 
So this is my new idea. I want my skills list to be just a set of options
admin can enter and a user can select from but selecting them will come in a
form of a select drop down box of Years
 
So the form would end up looking like:
 
skill1 [dropdown of years]
skill2 [dropdown] and so on
 
dropdown would save the year_id so the years table would be id, range
 
So the data being saved would be profile_id, skill_id and year_id in
profiles_skills?  but make profiles_skills a belongTo and hasMany
relationship not a HABTM? 
Add to add just a little more fun to my attempt I want to include an ajax
form made of a single input and the year drop down to add skills that are
not in the list available to select from in case a user has something not in
the list. So my guess is this would be 
additional_profiles_skills which has 
profile_id, 
year_id,
name?
 
Does this make sense? Right names and such?
 
Thanks
 
Dave

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: Need help: How can I use xdebug to debug Cake shells?

2009-12-23 Thread Matt Curry
I'm not sure how to do this in a general way.  In Komodo IDE go to
Debug in the menu, then Step In.
You have to change the Script input to point to cake/console/cake.php
and put the Script Arguements to be the name of the shell.
Doing it this way will break at the points you setup in the IDE.

Hope that helps.
-Matt
http://www.pseudocoder.com


On Dec 22, 10:52 am, Laran Evans laran.ev...@gmail.com wrote:
 I've read oodles of documentation, I can't find anything anywhere that
 covers how to use xdebug to debug PHP CLI scripts, let alone with
 those written as Cake shells.

 This is a huge issue for me right now. Can anyone shed some light on
 this? Thanks.

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: 1.3 JsHelper getting started - basic question

2009-12-23 Thread stefano
try with $Js

On Tue, Dec 22, 2009 at 11:41 AM, camillemoussette
camillemousse...@yahoo.com wrote:
 Hello,

 I'm trying to use the new JsHelper in 1.3 but I'm hitting a (stupid)
 wall. Whenever I follow the code from the documentation or the
 examples available online, I always get this error

 Notice (8): Undefined variable: js [APP/views/layouts/default.ctp,
 line 106]

 It seems that the JsHelper is not loading properly and the $js object
 is not assigned. Can you help? It must be super simple. I get the
 proper javascript output in the head and all.

 I have in my app_controller.php
 var $helpers = array('Js' = array('Jquery'));

 and

 my in my view, just before the body tag
 ?php echo $js-writeBuffer(); ?

 PS. I'm following Mark's tutorial at
 http://mark-story.com/posts/view/creating-simple-ajax-pagination-with-cakephp-1-3-and-mootools

 Thanks


 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




-- 
Stefano Salvatori M.
http://stefano.salvatori.cl/

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


Validation problem wtih required flag set

2009-12-23 Thread Philip


Hi all,

I have been reading posts on the confusion over required flag and I
think I understand it pretty well.

However I am having problem trying to make it work.

For example, here is my call:

$this-User-validate(array('User'=array('username'='test')));

And for the model, I have just one rule, which is notEmpty with
required set to true.

Odd thing is that if I use a html FORM to post ($this-User-validate
($_POST['data']), then it works, but not when I invoke it directly.

I am wondering if this has anything to do with the way I structure the
data array?

Any ideas would be appreciated, many thanks in advance.

Philip

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


using the session object

2009-12-23 Thread Josh
I have a fairly large array that I would like to access across http
requests in a given session.

Is there a performance disadvantage to putting this in the session
object?

The other option it seems is to put the data in the db, but I have no
need for this data to persist across sessions, so it seems
unnecessary.

Thanks.

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: Adaptive pagination

2009-12-23 Thread Jeremy Burns
This isn't a full answer but will hopefully help your thinking.

You could build a custom element that includes some logic around the
current page, which is reached via $paginator-current(). You could
then build links to the previous (say) five pages and the next five
pages, with some logic to make sure you don't go past the first or
last page. Then you can prefix this with links to pages 1 and 2, and
suffixed by the penultimate and last page.

The $paginator-numbers() function can take a 'modulus' option that
determines how many pages to show either side of the current page,
which will sort that part out for you;

echo $paginator-numbers(array('modulus' = 4, 'separator' = '|'));

I notice that although the document says modulus determines how many
pages to show either side of the current page it is actually the total
number of pages.

Here's a rough attempt for you. This doesn't include any logic around
$paginator-current(), but I am sure you can weave that in. Place this
in a file called pagination.ctp in views/elements and drop it into a
view

?php
$paginator-options(array('update' = 'content', 'indicator' =
'working'));

echo 'div class=pagingdiv id=page-numbers';

echo $paginator-first('');
echo 'nbsp;';
echo $paginator-prev('');
echo 'nbsp;';

echo $paginator-numbers(array('modulus' = 4, 'separator' = ' 
'));

echo 'nbsp;';
echo $paginator-next('');
echo 'nbsp;';
echo $paginator-last('');

echo  '/div/div';

?

I hope that helps a bit.

On Dec 23, 6:37 pm, NeoWebTech deva.in...@gmail.com wrote:
 Hello!

 I want to create a pagination for a huge/large number of items. But,
 the default pagination component is not good when the number of pages
 increases. So, I want to display like the following

 « Previous 1 2 … 5 6 7 8 9 10 11 12 13 … 2789 2790 Next »

 Please, let me know if there is any plug-in/code available.

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: 1.3 JsHelper getting started - basic question

2009-12-23 Thread Walther
The correct way in 1.3 is $this-Js

On Dec 23, 9:19 pm, stefano ssalvat...@gmail.com wrote:
 try with $Js

 On Tue, Dec 22, 2009 at 11:41 AM, camillemoussette



 camillemousse...@yahoo.com wrote:
  Hello,

  I'm trying to use the new JsHelper in 1.3 but I'm hitting a (stupid)
  wall. Whenever I follow the code from the documentation or the
  examples available online, I always get this error

  Notice (8): Undefined variable: js [APP/views/layouts/default.ctp,
  line 106]

  It seems that the JsHelper is not loading properly and the $js object
  is not assigned. Can you help? It must be super simple. I get the
  proper javascript output in the head and all.

  I have in my app_controller.php
  var $helpers = array('Js' = array('Jquery'));

  and

  my in my view, just before the body tag
  ?php echo $js-writeBuffer(); ?

  PS. I'm following Mark's tutorial at
 http://mark-story.com/posts/view/creating-simple-ajax-pagination-with...

  Thanks

  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.com For more options, visit this group 
  athttp://groups.google.com/group/cake-php?hl=en

 --
 Stefano Salvatori M.http://stefano.salvatori.cl/

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: Validation problem wtih required flag set

2009-12-23 Thread Dr. Loboto
When cake validates fields it first checks for field existence in data
array. If there is no such key, with required=true cake invalidate it,
with required=false cake skip it. So this flag behave exactly as it is
named. If field is required it must be present in data array.

On Dec 24, 1:21 am, Philip philip...@gmail.com wrote:
 Hi all,

 I have been reading posts on the confusion over required flag and I
 think I understand it pretty well.

 However I am having problem trying to make it work.

 For example, here is my call:

 $this-User-validate(array('User'=array('username'='test')));

 And for the model, I have just one rule, which is notEmpty with
 required set to true.

 Odd thing is that if I use a html FORM to post ($this-User-validate
 ($_POST['data']), then it works, but not when I invoke it directly.

 I am wondering if this has anything to do with the way I structure the
 data array?

 Any ideas would be appreciated, many thanks in advance.

 Philip

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: Non existent class method NOT throwing an error

2009-12-23 Thread Dr. Loboto
All depends on API class:
http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.methods

On Dec 22, 1:35 am, RhythmicDevil rhythmicde...@gmail.com wrote:
 I am very confused.  If I do the following:
 ?php
 class MyClass
 {

         public function mymethod()
         {
                 print This is my method;
         }

 }

 $cl = new MyClass();

 $cl-mymethod();

 $cl-no_method();
 ?

 The call to no_method() will throw an error. However when I am using
 CakePHP this does not seem to be the case.

 Please consider the following:

 $api_resp = $this-API-AddWorkOrder($this-Session-read
 ('Subscriber.SubscriberId'), CHANGE_EQUIPMENT, WO_OWNER, $devices);

 The AddWorkOrder method does not exist but I get no errors or warnings
 even with error reporting set to max.

 What am I missing?

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