From: Darius <da...@m2...> - 2006-03-03 09:22:09
|
Hi Alfredo, my code looks like this: $sql =3D "Select * from table order by x" $sqlCount =3D "Select count(*) from table" (without order and limit) But it'is not good for performance. Best regards, Darius ----- Original Message -----=20 From: Alfredo Yong=20 To: Darius=20 Cc: ado...@li...=20 Sent: 2006 m. kovo 2 d. 14:28 Subject: Re: [ADodb-general] Re: adodb execute method Hi Darious, I use a code like this: $SQL =3D "select * from table1"; $SQLCount =3D "select count(*) from ($SQL)"; Then I use $SQLCount to know the row count, and $SQL with a = SelectLimit But Im afraid the cost of this two queries is more than double the = original ($SQL) query Any better idea? greetings, =20 On 3/2/06, Darius <da...@m2...> wrote:=20 Hi all, we have also the same problem. With selectLimit(..) I retrieve only needed rows. But there need to = know count of all rows.=20 In MySQL I can do this with SQL_CALC_FOUND_ROWS. What is solution in = AdoDB ? Best regards, Darius Marcin Szkudlarek wrote: > Thanks for reply. You are right - I want to implement paging but = it"s=20 > not that simple. I want to select 100 rows from 50k table but I = don"t > know how much rows I have to fetch to get the 100 .. it could be = in > the WORST case the last 100 from the whole 50k table. I"t because = I"m=20 > checking access rights to every row in php and then diplaying it = or > not. So your example with selecting only first 100 rows from the = table > woudn"t work here. If there isn"t a way to fetch the result row by = row=20 > I"ll have to reimplement some ugly code. > You have just described the classic poorly designed application. = ;-) >If there"s something in the data that you can look at and determind >access rights in PHP, then you should move that logic to your SQL = query >and select only the rows you"re interested in. > > Best regards, > > Marcin Szkudlarek > > On Fri, 24 Jun 2005, Emil Zegers wrote:=20 > >> What do you exactly mean by "fetching the rows"? >> >> If you want to do a row count then your query could be something = like >> "SELECT COUNT(*) FROM TABLENAME"=20 >> >> If you want to get only a certain amount of rows you can do = something >> like "SELECT TOP 100 * FROM TABLENAME". >> >> Also take a look at paging options. >>=20 >> If you do want to get the data in a recordset for manipulation = you >> really have to fetch it. >> >> You can limit the data (and thus the query time) by selecting = only the >> columns needed.=20 >> >> Regards, >> >> Emil >> >> -----Original Message----- >> From: adodb-general-admin@li... >> [mailto:adodb-general-admin@li ...] On Behalf Of Marcin >> Szkudlarek >> Sent: vrijdag 24 juni 2005 11:49 >> To: adodb-general@li... >> Subject: [ADodb-general] adodb execute method >> >> Hi! >> >> I"m using ado 4.62 with oracle 8.17. My question: >> is there a way to execute select query without getting all the = results? >> I have a table with about 50k records and calling only the = execute=20 >> method takes about 1,8s. What I want to achieve is fetching the = rows >> without having to get all the data at once. >> >> Thanks. >> >> Marcin Szkudlarek --=20 Alfredo Yong Sistemas web |