Problem with Paginator

2010-01-20 Thread Ernesto
Hello.
i have 2 models linked together with a simple hasMany relationship.

Customer hasMany Order // Order belongTo Customer

Customers are stored in an external DB so the Customer model uses a
different DB connection

now... i coded 2 views:
customers/index and orders/index

- customers/index. This view is displaying ONLY customer data -- i
can order by customer.name without problems

- orders/index. This view displays the order data (including
customer's name) -- when i try to order by Customer.name i get an
error like this:

Warning (512): SQL Error: 1054: Unknown column 'Customer.name' in
'order clause' [CORE\cake\libs\model\datasources\dbo_source.php, line
635]

and the table won't order.

i guess the DB Connection is the culprit.

is there any solution/workaround?

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


Re: weird problem with paginator (Cake 1.3)

2009-12-22 Thread Ernesto
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


Re: weird problem with paginator (Cake 1.3)

2009-12-22 Thread mark_story
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


weird problem with paginator (Cake 1.3)

2009-12-21 Thread Ernesto
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


Re: Problem with paginator

2009-04-16 Thread sbutch

Sorry, but I still don't understand why this work:

?php echo $paginator-last('last', array('url'=0));?

and produce this correct link:  http://127.0.0.1/assysts/index/0/page:6

and this not:

?php echo $paginator-next('next',array('url'=0),null, array
('class'='disabled'));?

and  produce this crazy link: http://127.0.0.1/assysts/next



On Apr 15, 8:34 pm, Stu greenmushroo...@gmail.com wrote:
 the next and prev functions from paginator require an Options array
 as the second argument as you are currently giving it a boolean.  You
 might want to go check out the paginator helper line 189 and 201.

 Good luck,

 Stu

--~--~-~--~~~---~--~~
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: Problem with paginator

2009-04-16 Thread sbutch

I have solved.
Problem was that the behavior of array_merge() was modified in PHP 5.
Unlike PHP 4, array_merge()  now only accepts parameters of type
array.

So I have modified line 312 of paginator.php helper, with a typecast:


It was:$url = array_merge(array('page' = $paging['page'] +
($which == 'Prev' ? $step * -1 : $step)), $url);
now is: $url = array_merge(array('page' = $paging['page'] + ($which
== 'Prev' ? $step * -1 : $step)), (array)$url);

and now it seems to work. Hope will help!



On Apr 15, 8:34 pm, Stu greenmushroo...@gmail.com wrote:
 the next and prev functions from paginator require an Options array
 as the second argument as you are currently giving it a boolean.  You
 might want to go check out the paginator helper line 189 and 201.

 Good luck,

 Stu

--~--~-~--~~~---~--~~
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: Problem with paginator

2009-04-16 Thread sbutch

Sorry, but I still don't understand why this work:

?php echo $paginator-last(' ', array('url'=0));

and produce this correct link: http://127.0.0.1/assysts/index/0/page:6

and this not:

?php echo $paginator-next(' ', array('url'=0), null,
array('class'='disabled'));

and produce this crazy link: http://127.0.01/assysts/



On Apr 15, 8:34 pm, Stu greenmushroo...@gmail.com wrote:
 the next and prev functions from paginator require an Options array
 as the second argument as you are currently giving it a boolean.  You
 might want to go check out the paginator helper line 189 and 201.

 Good luck,

 Stu

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem with paginator

2009-04-15 Thread sbutch

I have a problem using paginator with filter, using cake version :
1.2.2.8120.

this is my controller. It shows only elements that have a particular
value for $attivo  (i.e.1 or 0):

?php
class AssystsController extends AppController {
var $name = 'Assysts';
var $helpers = array('Html', 'Form');

function index($attivo = 1) {
$this-Assyst-recursive = 0;
$this-set('assysts', $this-paginate('Assyst', array
(Assyst.attivo = $attivo)));
$this-set(compact(attivo));
}
}



In the view I habe put  this paginator, to propagate the filter to
next pages too:

div class=paging
?php echo $paginator-first(' '.__('first', true), array
('url'=$attivo), null, array('class'='disabled'));?
?php //echo $paginator-prev(' '.__('previous', true), array
('url'=$attivo), null, array('class'='disabled'));?
 |  ?php echo $paginator-numbers(array('url'=$attivo));?
?php //echo $paginator-next(__('next', true).' ', array
('url'=$attivo), null, array('class'='disabled')); ?
?php echo $paginator-last(__('last', true).' ', array
('url'=$attivo), null, array('class'='disabled'));?
/div


Now, links to first, last and numbered pages work nice.
The problems are with the link for prev and next pages: the link
doesn't work and and it produces this warning:

Warning (2): array_merge() [function.array-merge]: Argument #2 is not
an array [CORE/cake/libs/view/helpers/paginator.php, line 312]

Any idea?

--~--~-~--~~~---~--~~
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: Problem with paginator

2009-04-15 Thread Stu

the next and prev functions from paginator require an Options array
as the second argument as you are currently giving it a boolean.  You
might want to go check out the paginator helper line 189 and 201.

Good luck,

Stu
--~--~-~--~~~---~--~~
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: Problem with paginator ajax links without javascript code

2008-07-12 Thread pvilas

Ok, problem solved. It was a mistake with the action parameters.

Anyway, be careful with the behaviour of Firefox when it is spending a
lot of memory.

On Jul 9, 6:53 pm, pvilas [EMAIL PROTECTED] wrote:
 I have some paginated views that when first ajax rendered the paginator links
 no longer work. It's a bit odd because, traced with firebug, the post to the
 server returns the ajax code for the links but the browser doesn't include
 the javascript in the code!

 Returned post code:
 ...
 /Premios/vista_cliente/page:1 lt;lt; Prev script
 type=text/javascriptEvent.observe('link1251262658',
  'click', function(event) { new
 Ajax.Updater('contTaulaPremios','/Premios/vista_cliente/page:1',
 {asynchronous:true, evalScripts:true, onLoading:function(request)
 {Element.show('spinnerPremios');}, onComplete:function(request, json)
 {Element.hide('spinnerPremios');}, requestHeaders:['X-Update',
 'contTaulaPremios']}) }, false);/script | div class=disabledNext
 gt;gt;/div
 ...

 Code the browser renders:
 ...
 /Premios/vista_cliente/page:1  Prev
 |
 div class=disabledNext /div...
 --
 View this message in 
 context:http://www.nabble.com/Problem-with-paginator-ajax-links-without-javas...
 Sent from the CakePHP mailing list archive at Nabble.com.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Problem with paginator ajax links without javascript code

2008-07-09 Thread pvilas


I have some paginated views that when first ajax rendered the paginator links
no longer work. It's a bit odd because, traced with firebug, the post to the
server returns the ajax code for the links but the browser doesn't include
the javascript in the code!

Returned post code:
...
/Premios/vista_cliente/page:1 lt;lt; Prev script
type=text/javascriptEvent.observe('link1251262658',
 'click', function(event) { new
Ajax.Updater('contTaulaPremios','/Premios/vista_cliente/page:1',
{asynchronous:true, evalScripts:true, onLoading:function(request)
{Element.show('spinnerPremios');}, onComplete:function(request, json)
{Element.hide('spinnerPremios');}, requestHeaders:['X-Update',
'contTaulaPremios']}) }, false);/script | div class=disabledNext
gt;gt;/div 
...

Code the browser renders:
...
/Premios/vista_cliente/page:1  Prev 
|
div class=disabledNext /div...
-- 
View this message in context: 
http://www.nabble.com/Problem-with-paginator-ajax-links-without-javascript-code-tp18366115p18366115.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---