Re: [PHP3] Subject: Oracle 8 + PHP Next/Prev records
| From: | (Richard Lynch) | Date: | Wed, 21 Jun 2000 00:33:58 +0000 |
| Subject: | Re: [PHP3] Subject: Oracle 8 + PHP Next/Prev records | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2415@lists.php.net to get a copy of this message | ||
In article <E19BD59ED391D111B42E006008990CF41244EB@MEDIA>,
john.cav@sapiens.com (John Cavacas) wrote:
> Hey guys.
>
> I'm developing a few data driven pages with PHP and Oracle 8. I'm using the
> OCI functions in PHP to do so. My problem is I have a long list of titles
> that need to be pulled out of the DB, and I want to show them 10 at a time.
> Clicking next gives you the next 10 titles, etc, etc.
>
> Now, in MySQL we have the LIMIT function, but there is no such function in
> Oracle. The closest I have found is ROWCOUNT which can be given a < or >
> value. I've also haven't seen any Oracle sample code to accomplish this, and
> i'm sure i'm not the first person to need something like this ;) So far no
> luck, i'm still trying a few things, but I would appriciate some code or
> ideas to try. Thanks in advance.
Oracle has this thing called a "cursor" which is how you do that.
Something not unlike this is what you'll end up with, except I know squat
about Oracle:
//Set up some vars for page-size and start row:
if (!isset($start)){
$start = 0;
}
$limit = 10;
$sql = "create cursor foo select title from titles order by title";
$cursor = oci_exec($connection, $sql) or die($sql);
$sql = "move foo forward $start";
$move = oci_exec($connection, $sql) or die($sql);
$sql = "select title from foo";
for ($i = 0; $i < $limit; $i++){
$title = oci_exec($connection, $sql) or die($sql);
echo oci_result($title, 0, 0), "<BR>\n":
}
Dig through the Oracle manual for "cursor" or search the code archvies.
Oh yeah, there's a PHP Oracle mailing list somewhere, isn't there? Not an
official PHP list, but out there somewhere.
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)