Message from discussion
Problem with paged Doctrine in using Doctrine Query -> offset to the query page
Received: by 10.210.142.6 with SMTP id p6mr138849ebd.1.1246569260223;
Thu, 02 Jul 2009 14:14:20 -0700 (PDT)
Return-Path: <szabolcs.hei...@gmail.com>
Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25])
by gmr-mx.google.com with ESMTP id 16si666801ewy.7.2009.07.02.14.14.19;
Thu, 02 Jul 2009 14:14:19 -0700 (PDT)
Received-SPF: pass (google.com: domain of szabolcs.hei...@gmail.com designates 74.125.78.25 as permitted sender) client-ip=74.125.78.25;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of szabolcs.hei...@gmail.com designates 74.125.78.25 as permitted sender) smtp.mail=szabolcs.hei...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by ey-out-2122.google.com with SMTP id 9so486724eyd.53
for <doctrine-user@googlegroups.com>; Thu, 02 Jul 2009 14:14:19 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:mime-version:received:in-reply-to:references
:date:message-id:subject:from:to:content-type;
bh=2S4HKyyX8ZVZJ7SQLLWhNZvqoQ8WaYJLsqYtI491Ok4=;
b=tmX3jfhyyB3UUfIoPoxuMm0x0U74LPa63X/1EcGgRqg1Qr6uBSTcZgJHnG1KPPLRVs
nEYrDz8OezliPu73CO5F6oTHIki5Gbsa4QIegmTW+untBw5sPf8/TtviejJa6AmcjTXx
2NlWuNoOPbJdJRSKidpj0wbica5g0KsD1l7Hs=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type;
b=mqlqPW+X7SItsEV876pl2841I1zUy4UcOIum14PIXc4sk+Qf8QS3bbidqa2KVgVMJX
SzGnkwIUV1NmmI5XqogJh5VSTso6U01+Y/dapshh8MNyJgazJAU1O34FmKI5Fstk/eze
17dIXCthXbqx8/KNaxi35NCOUITTpB8AoU2IE=
MIME-Version: 1.0
Received: by 10.216.18.212 with SMTP id l62mr142218wel.76.1246569258559; Thu,
02 Jul 2009 14:14:18 -0700 (PDT)
In-Reply-To: <0d41dd89-7094-47e4-af44-47ba92d300a2@y9g2000yqg.googlegroups.com>
References: <0d41dd89-7094-47e4-af44-47ba92d300a2@y9g2000yqg.googlegroups.com>
Date: Thu, 2 Jul 2009 23:14:18 +0200
Message-ID: <bd2145680907021414u649db2ecoff28d194451ce...@mail.gmail.com>
Subject: Re: [doctrine-user] Problem with paged Doctrine in using Doctrine
Query -> offset to the query page
From: Szabolcs Heilig <szabolcs.hei...@gmail.com>
To: doctrine-user@googlegroups.com
Content-Type: multipart/alternative; boundary=001636499603d82906046dbf85cb
--001636499603d82906046dbf85cb
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hello,
To get closer tho know what does Doctrine in that case,
(your offset is out of the bound) check the generated SQL with:
echo $query->getSql();
You can check the generated SQL with that step.
2009/7/2 Nixs <acron...@gmail.com>
>
> hello. I'm in a weird situation. I need to paginate
> and show 10 results per query does pagina.mi correctly.
> Then -> offset (10) in the query shows the following 10
> results.
> The question is what does it correctly. The problem is that when
> asks a page, for example the number 500, which is not logically
> There, instead of not returning anything, I devulve ALL!
>
> here's the code:
>
> public static function buscarProductos($tiendaId,$cantResultados =
> 10,$offSet){
>
> $query= Doctrine_Query::create()
> ->select
> ('p.id,ip.id,p.precio,p.descripcion,p.titulo,p.moneda,c.id,c.nombre')
> ->from('Producto p,p.ImagenesProducto ip,p.Categoria
> c')
> ->addWhere('p.tienda_id='.$tiendaId)
> ->orderBy('p.id desc')
> ->limit($cantResultados)
> ->offSet($offSet)
> ->execute(array(),Doctrine::HYDRATE_ARRAY);
>
> return $query;
>
>
--001636499603d82906046dbf85cb
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hello,<br><br>To get closer tho know what does Doctrine in that case,<br>(y=
our offset is out of the bound) check the generated SQL with:<br><br>echo $=
query->getSql();<br><br>You can check the generated SQL with that step.<=
br>
<br><div class=3D"gmail_quote">2009/7/2 Nixs <span dir=3D"ltr"><<a href=
=3D"mailto:acron...@gmail.com">acron...@gmail.com</a>></span><br><blockq=
uote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 20=
4); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
hello. I'm in a weird situation. I need to paginate<br>
and show 10 results per query does pagina.mi correctly.<br>
Then -> offset (10) in the query shows the following 10<br>
results.<br>
The question is what does it correctly. The problem is that when<br>
asks a page, for example the number 500, which is not logically<br>
There, instead of not returning anything, I devulve ALL!<br>
<br>
here's the code:<br>
<br>
public static function buscarProductos($tiendaId,$cantResultados =3D<br>
10,$offSet){<br>
<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$query=3D Doctrine_Query::create()<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->select<br>
('<a href=3D"http://p.id" target=3D"_blank">p.id</a>,<a href=3D"http://=
ip.id" target=3D"_blank">ip.id</a>,p.precio,p.descripcion,p.titulo,p.moneda=
,<a href=3D"http://c.id" target=3D"_blank">c.id</a>,c.nombre')<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->from('Producto p,p.ImagenesProduct=
o ip,p.Categoria<br>
c')<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->addWhere('p.tienda_id=3D'.$tie=
ndaId)<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->orderBy('<a href=3D"http://p.id" t=
arget=3D"_blank">p.id</a> desc')<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->limit($cantResultados)<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->offSet($offSet)<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->execute(array(),Doctrine::HYDRATE_ARRA=
Y);<br>
<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return $query;<br>
<br>
</blockquote></div><br>
--001636499603d82906046dbf85cb--