MAYBE THERES ANOTHER WAY; but before selecting or fertching all you wont
know
Are you saying that, in php, every query has to be perfomed twice, if you
want
to know the number of rows in selection (before the fetch loop)?
Matthias Kopolt wrote:
> OK:
>
> imagine you want to find all rows wher
Are you saying that, in php, every query has to be perfomed twice, if you want
to know the number of rows in selection (before the fetch loop)?
Matthias Kopolt wrote:
> OK:
>
> imagine you want to find all rows where COLOR = 'foo' :
>
> $st1 = ociparse ($conn, "SELECT count(*) FROM myTable WH
>and to get rows, say, from 20 to 40?
>Is it ok to write:
>"select * from (select * from table where foocondition order by foo) where
>rownum >= 20 AND rownum <= 40"
its not that easy, as oracle start counting with the first retrieved row, so
rownum > x will wait for ever, as oracle will never st
OK:
imagine you want to find all rows where COLOR = 'foo' :
$st1 = ociparse ($conn, "SELECT count(*) FROM myTable WHERE COLOR =
'foo'");
ociexecute($st1,OCI_DEFAULT);
ocifetch ($st1);
$number_of_rows = ociresult ($st1, 1); //e.g. 372
$st2 = ociparse ($conn, "SELECT ID, NAME FROM myTable
you can use the meta column rownum
e.g. where rownum<20
note: you need to do subselects and (where rownum > 1) will never return a
line !!!
you could use something like
select * from
select rownum "rownumber", mydata from mytable order by
mycol
) where rownumber