Re: Fetching PEAR DB in a set
| From: | Sanjay | Date: | Mon, 22 Dec 2003 23:56:38 +0000 |
| Subject: | Re: Fetching PEAR DB in a set | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9786@lists.php.net to get a copy of this message | ||
I have already gone thru example mentioned by you but as you said, it is not what I want.
I am new to PHP world and I am Oracle DBA so I am thinking from dba point to view. The example
below, still fetches 1 by 1 records. I don't know whether each fetch from PEAR DB causes 1 trip
to oracle to get data back.
I have only 2 questions in my mind.
1. Does every fetche causes one oracle round trip ?
2. If I use getAll method, what is impact on memory if # of rows returned are large.
Thanks
Sanjay
----- Original Message -----
From: Graham Clarke
To: Sanjay ; pear-general@lists.php.net
Sent: Monday, December 22, 2003 6:50 PM
Subject: Re: [PEAR] Fetching PEAR DB in a set
Sanjay - have a look here http://vulcanonet.com/soft/?pack=pear_tut#ss3.3.4
Here's the example -- No quite what you want
// the row to start fetching
$from = 50;
// how many results per page
$res_per_page = 10;
// the last row to fetch for this page
$to = $from + $res_per_page;
foreach (range($from, $to) as $rownum) {
if (!$row = $res->fetchrow($fetchmode, $rownum)) {
break;
}
$id = $row[0];
....
}
Cheers
Graham
At 03:23 PM 12/22/2003 -0800, Sanjay wrote:
Thanks Graham,
I have looked PEAR DB manual and also MDB documentation. I have seen methods
to get one row or all rows.
I know, I can loop thru recordset without any problems but what I am asking
is different.
1. Suppose, If I execute a query which returns 1 million records, so I can
do DB_Common::getRow() -- fetch the first row or do DB_Common::getAll() --
Fetch all rows , how is memory handling, if I do DB_Common::getAll. I
don't know how is memory handled in getAll case . Will it create memory
problems when data is very big.
2. The method which mentioned above, gives fetch 1 row or all rows but what
I want is to fetch in batches, in oracle terms, it is called array Fetch or
Bulk Fetch (PLSQL) and I can define how many records, I want to fetch at one
time so e.g. if I query returns 1000 records and if I say in one fetch
return 100 recors so there will be just 10 trips to fetch all data so my
question is how can I do this in PEAR DB or MDB
Sanjay
----- Original Message -----
From: "Graham Clarke" <grahamc@53tech.com>
To: "Sanjay" <sanjay92@hotmail.com>; <pear-general@lists.php.net>
Sent: Monday, December 22, 2003 4:46 PM
Subject: Re: [PEAR] Fetching PEAR DB in a set
> Check the docs on pear.php.net for best description -- you have choices
>
> $result = _however_you_get_your_PEAR::DB_recordset()
>
> // this creates an indexed array $my_data where each row is an associative
> array w/ keys = column names
> while ($r = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
>
> $my_data[] = $r;
>
> }
>
> At 09:26 AM 12/22/2003 -0800, Sanjay wrote:
> >How do I fetch say 20 records at a time. I am using Oracle database.
> >Suppose my query returns 1000 records but I want to fetch 20 records at
on
> >time and then display these 20 records on your page and then you keep
> >fetching next 20 records and so on.. How should I do it in PEAR DB.
> >
> >Thanks
> >Sanjay
>
>
> Graham Clarke
> GrahamC@53Tech.com
> www.53Tech.com
> 603.643.9955
>
>
Graham Clarke
GrahamC@53Tech.com
www.53Tech.com
603.643.9955