Paging results on PHP/Oracle

Does anybody have a clean code they can share about paging query resultset on PHP using OCI (not ADO or something else)???
I've tried some posted here but the results is not encouraging ...

Look at
http://asktom.oracle.com/pls/ask/f?p=4950:8:12499734965902645361::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:127412348064
A working example in SQL*Plus:
arc@sles> var nrows number;
arc@sles> var offset number;
arc@sles> exec :nrows := 3;
PL/SQL procedure successfully completed.
arc@sles> exec :offset := 5;
PL/SQL procedure successfully completed.
arc@sles> select rowno,empno,ename from
2 (select rownum as rowno,empno,ename from
3 (select * from scott.emp order by empno)
4 where rownum <= :offset + :nrows)
5 where rowno >:offset;
ROWNO EMPNO ENAME
6 7654 MARTIN
7 7658 CHAN
8 7698 BLAKE
The same in PHP could like something:
$stmt = OCIParse($conn,"select rowno,empno,ename from
(select rownum as rowno,empno,ename from
(select * from scott.emp order by empno)
where rownum <= :offset + :nrows)
where rowno >:offset");
OCIBindByName($stmt,":nrows",$nrows,10);
OCIBindByName($stmt,":offset",$offset,10); ...

Similar Messages

  • PHP/ORACLE Pagination

    Hi All,
    Can any one help me to create PHP/ORACLE Pagination..
    Thanks
    Sam

    Hi pals
    Here is a good easy sample of pagination using Oracle in PHP, Please notice that I have a layer, running different queries which I need, and in some lines below I've used them but the names of the function and variable which I've called are obviously seen that how they perform.
    Further, Please note that you would be expected to call your own oracle database through PHP oracle functions, and as you can see, I have a table storing page sessions and the function "oracle->select" runs the query "SELECT * FROM SESSION_ID" and returns its result and the variable "numberrows" has the number of rows which the implemented query has returned.
    <html>
    <head>
    <title>PAGING</title>
    </head>
    <body>
    <?
    session_start();
    $session_check = $orcl->oracle_select("SESSION_ID", "*");
    $Per_Page = 10; // Per Page
    $Num_Rows = $orcl->numberrows;
    if( !isset( $_GET["Page"] ) )
         $Page=1;
    else
    $Page = $_GET["Page"];
    $Prev_Page = $Page-1;
    $Next_Page = $Page+1;
    $Page_Start = ( ( $Per_Page*$Page ) - $Per_Page );
    if( $Num_Rows <= $Per_Page )
         $Num_Pages =1;
    else if( ( $Num_Rows % $Per_Page ) == 0 )
         $Num_Pages = ( $Num_Rows / $Per_Page );
    else
         $Num_Pages = ( $Num_Rows / $Per_Page ) + 1;
         $Num_Pages = (int)$Num_Pages;
    $Page_End = $Per_Page * $Page;
    if ( $Page_End > $Num_Rows )
         $Page_End = $Num_Rows;
    ?>
    <table width="800" border="1" cellpadding="0" cellspacing="0" style="font-size: 12px; font: Tahoma">
    <tr>
    <th width="400" align="center">CUSTOMER</th>
    <th width="400" align="center">Name</th>
    </tr>
    <?
    for($i=$Page_Start; $i<$Page_End; $i++)
    ?>
    <tr>
    <td width="400" align="center"><div align="center"><?=$session_check["ID"][$i]; ?></div></td>
    <td width="400" align="center"><?=$session_check["USER_ID"][$i];?></td>
    </tr>
    <?
    ?>
    </table>
    <table width="800" border="0" cellpadding="0" cellspacing="0" style="font-size: 12px; font: Tahoma">
    <tr>
    <td align="center"> </td>
    </tr>
    <tr>
    <td align="center">Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :</td>
    </tr>
    <tr>
    <td align="center">
    <?
    if($Prev_Page)
         echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
    for($i=1; $i<=$Num_Pages; $i++){
         if($i != $Page)
              echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
         else
              echo "<b> $i </b>";
    if($Page!=$Num_Pages)
         echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
    ?>
    </td>
    </tr>
    <tr>
    <td align="center"> </td>
    </tr>
    </table>
    </body>
    </html>

  • Errors in PHP/Oracle article

    Hi,
    There are a few errors in the article dealing with PHP/Oracle located at http://otn.oracle.com/oramag/webcolumns/2003/techarticles/hull_php.html
    In the listing for the section called "How to use a database":
    - $mycursor ora_open ($conn);
    should be
    $mycursor = ora_open ($conn);
    - echo "RESULT: ora_getcolumn ($mycursor, 0), ora_getcolumn ($mycursor, 1) <br>";
    The above is not the way it works in PHP and you won't get the expected results. You can throw variables in between your double-quote delimited strings, but not function calls. You'll have to concatenate the function calls like this:
    echo "RESULT: ".ora_getcolumn ($mycursor, 0).", ".ora_getcolumn ($mycursor, 1)."<br>";

    Leendert:
    Thanks for the comments. The first one is an obvious typo. The second
    is a pretty obvious mistake which I missed while reviewing this. Although
    PHP will expand variables in a string like that, it will not handle
    function calls. How could it. I just tried it, and concatenation works
    just as you suggest. Thanks for the corrections, and we updated the
    article.
    Sean

  • PHP  Oracle editor/administration

    Jeg har installeret Oracle XE og PHP og det går helt fint, men jeg kunne godt tænke mig en PHP-Oracle editor/administrator. Jeg har før brugt PHPMyadmin mellem PHP og Mysql og mener at der findes noget tilsvarende til Oracle, men kan ikke umiddelbart finde det. Er der nogen der kan hjælpe.
    HBC

    Hi, pbarut I modified the settings of browsers and added the html code below:
    <?php
    header("Expires: Thu, 17 May 2001 10:17:17 GMT");
    header ("Last-Modified: Thu, 17 May 2001 10:17:18 GMT");
    header ("Cache-Control: no-cache, must-revalidate");
    header ("Pragma: no-cache");
    ?>
    But the problem continues.
    When I update the site (CTRL + F5) results viewing, but do not appear when the redirect or click any link.
    Tanks

  • Php-oracle workspace

    hi,
    you think that i have a one textbox and one button on my webpage, and i want to write ORacle code in textbox something like that
    begin
    dbms_output.put_line ('hello!');
    end;
    after that when i click on the button , i want to display result below.i am using php code to do that things. otherwise i am using oracle 10g express edition,i searched on the net ,and i find a website that exactly what i want to do. this website URL : http://193.140.164.123:5561/isqlplus/login.uix you can enter 'hr' for both username and password. there you can see Workspace.
    pls.if u know about this topic write here. thx.

    That's a pretty open ended question. Perhaps reading the OCI8 manual http://us.php.net/manual/en/book.oci8.php or getting one of the many fine PHP Oracle books will help get you started.

  • PHP- Oracle not working- Call to undefined function OCILogon() ERROR

    Hi,
    I am trying to just do a test program to test php - oracle connection,
    My versions are: php5.2.1-Win32 and Oracle 10g
    I have made the following settings:
    1.) Uncommented the following lines in php.ini:
    extension=php_oci8.dll
    extension=php_oracle.dll
    2.) Set extension_dir = "C:\php-5.2.1-Win32\ext"
    Changed the httpd.conf file as: ADDED
    1.)LoadModule php5_module C:/php-5.2.1-Win32/php5apache2.dll
    2.)PHPIniDir "C:/Program Files/Apache Group/Apache2/conf-"
    3.) LoadFile "C:/php/php5ts.dll"
    4.)<IfModule php5_module>
    <Location />
    AddType text/html .php .phps
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php-source .phps
    </Location>
    </IfModule>
    5.) AddType application/x-httpd-php .php
    AddType application/x-httpd-php .phtml
    AddType application/x-httpd-php-source .phps
    But when I am tryin to run the following program:
    <?php
    echo "<h1>OCI Test</h1>\n";
    $conn=OCILogon("system", "sheetal16", "orcl");
    $stmt = OCIParse($conn, "SELECT table_name FROM user_tables ORDER BY table_name");
    OCIExecute($stmt, OCI_DEFAULT);
    while (OCIFetch($stmt)) {
         $table_name = OCIResult($stmt, "TABLE_NAME");
         echo "$table_name<br />\n";
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>
    I am getting the following error:
    OCI Test
    Fatal error: Call to undefined function OCILogon() in C:\Program Files\Apache Group\Apache2\htdocs\test2.php on line 3
    Please help me to solve this problem.
    Thanks,
    Sheetal

    See Re: PHP- Oracle not working- Call to undefined function OCILogon() ERROR

  • Php, oracle connectivity.

    Hello All,
    I have a webserver that has php4,apache1.3 and oci8 instant client installed, and have a seperate oracle 10g db server, the php-oracle connectivity is fine when i run php code from db server but it gives me connectivity error when it runs from web server, error " ocifreestatement(): supplied argument is not a valid OCI8-Statement resource in /apache/htdocs/.....php on line..." while even when i made telnet to my db server 1521 port from web server it shows that listener is working, any idea ? thanks

    Hello,
    My developers have changed all the API´s to OCI8 and the code is able to connect with oracle 10g with php4 but, i am still getting this warning .i.e
    Warning: ocifreestatement(): supplied argument is not a valid OCI8-Statement resource in /apache/htdocs/English/tender_list.php on line 340
    i am unable to figure it out, every thing is working fine but still i am getting it ?
    thanks

  • Where to find documentation related to php-oracle

    Hi , i have been working with oracle ,and with php -mysql but never with php-oracle. I would like to ask if there are any samples application with orale-php and wich i can download.
    Another question is wich editor is better to use to program codes? I have been using dreamweaver. What else can you suggest me?
    Thanks in advance

    You can start with Oracle Underground Manual:
    http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
    I also wrote a book on the topic, available from Amazon.

  • How to limit the number of search results returned by oracle text

    Hello All,
    I am running an oracle text search which returned the following error to my java program.
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    #### ORA-29902: Fehler bei der Ausführung von Routine ODCIIndexStart()
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    java.sql.SQLException: ORA-29902: Fehler bei der Ausführung von Routine ODCIIndexStart()
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    When i looked up the net, one suggestion that was given is to narrow the wildcard query, which i cannot in my search page. Hence I am left with the only alternative of limiting the number of results returned by oracle text search query.
    Please let me know how to limit the number of search results returned by oracle text so that this error can be avoided.
    Thanks in advance
    krk

    Hi,
    If not set explicitly, the default value for WILDCARD_MAXTERMS is 5000. This is set as a wordlist preference. This means that if your wildcard query matches more than 5000 terms the message is returned. Exceeding that would give the user a lot to sift through.
    My suggestion: trap the error and return a meaningful message to the user indicating that the search needs to be refined. Although it is possible to increase the number of terms before hitting maxterms (increase wildcard_maxterms preference value for your wordlist), 5000 records is generally too much for a user to deal with anyway. The search is not a good one since it is not restricting rows adequately. If it happens frequently, get the query log and see the terms that are being searched that generate this message. It may be necessary to add one or more words to a stoplist if they are too generic.
    Example: The word mortgage might be a great search term for a local business directory. It might be a terrible search term for a national directory of mortgage lenders though (since 99% of them have the term in their name). In the case of the national directory, that term would be a candidate for inclusion in the stoplist.
    Also remember that full terms do not need a wildcard. Search for "car %" is not necessary and will give you the error you mentioned. A search for "car" will yield the results you need even if it is only part of a bigger sentence because everything is based on the token. You may already know all of this, but without an example query I figured I'd mention it to be sure.
    As for limiting the results - the best way to do that is to allow the user to limit the results through their query. This will ensure accurate and more meaningful results for them.
    -Ron

  • Results Of The Oracle Certification 2009 Salary Survey

    !http://blogs.oracle.com/certification/0116.jpg!
    *<p>The results of the Oracle Certification Program's 2009 Salary Survey, which was administered via the Internet earlier this year have been released.</p>*<p align="justify">Responses from Oracle Certification E-Magazine subscribers, Oracle Certified individuals, and visitors to the Oracle Certification Blog are included in the survey results - with participants from every demographic region worldwide.</p>
    <p align="justify"> Of the 2,337 individuals who responded to the survey, 95% are employed either full- or part-time and reported that those who are Oracle certified typically earn an average salary that is $10K higher than candidates who are not certified.</p>
    <p align="justify"> For full details, visit Oracle Certification 2009 Salary Survey Results.</p>

    Am I the only one who doesn't see any figures (tried in FF & IE). Selecting from the LOV makes the page load but selecting an option e.g. regional salary / experience doesn't show anything.
    Edit: Europe doesn't show actually.
    Mike
    Edited by: Dird on Nov 17, 2009 1:13 PM
    Edited by: Dird on Nov 17, 2009 1:15 PM

  • Unicode in php oracle

    While using multilanguage in php/oracle iam facing some issues
    i gave input as : Portuguese: O próximo vôo à
    and got output as : Portuguese: O pr?ximo v?o ?
    for some special characters it is replaced by '?' mark.
    iam using php5 and orcle 9 and OCI for connecting.
    i gave NLS_CHARACTERSET as UTF8
    and the unicode datatype as NVARCHAR2(100)
    Plz some one help me out in solving it

    hi..
    using alter session in php i changed my nsl_lang to PORTUGUESE
    but still the data is stored in ? for some special characers
    Array
    [PARAMETER] => Array
    [0] => NLS_LANGUAGE
    [1] => NLS_TERRITORY
    [2] => NLS_CURRENCY
    [3] => NLS_ISO_CURRENCY
    [4] => NLS_NUMERIC_CHARACTERS
    [5] => NLS_CALENDAR
    [6] => NLS_DATE_FORMAT
    [7] => NLS_DATE_LANGUAGE
    [8] => NLS_CHARACTERSET
    [9] => NLS_SORT
    [10] => NLS_TIME_FORMAT
    [11] => NLS_TIMESTAMP_FORMAT
    [12] => NLS_TIME_TZ_FORMAT
    [13] => NLS_TIMESTAMP_TZ_FORMAT
    [14] => NLS_DUAL_CURRENCY
    [15] => NLS_NCHAR_CHARACTERSET
    [16] => NLS_COMP
    [17] => NLS_LENGTH_SEMANTICS
    [18] => NLS_NCHAR_CONV_EXCP
    [VALUE] => Array
    [0] => PORTUGUESE
    [1] => AMERICA
    [2] => $
    [3] => AMERICA
    [4] => .,
    [5] => GREGORIAN
    [6] => DD-MON-RR
    [7] => PORTUGUESE
    [8] => UTF8
    [9] => WEST_EUROPEAN
    [10] => HH.MI.SSXFF AM
    [11] => DD-MON-RR HH.MI.SSXFF AM
    [12] => HH.MI.SSXFF AM TZR
    [13] => DD-MON-RR HH.MI.SSXFF AM TZR
    [14] => $
    [15] => AL16UTF16
    [16] => BINARY
    [17] => BYTE
    [18] => FALSE
    Input i gave : próximo vôo à
    out put : pr??ximo v??o ??

  • Paged Result Set

    Hi,
    It seems that the "rownum" is non-deterministic for the result set from Oracle Text.
    My goal is to present Oracle Text search results to end user page by page. So, what I did is to have a stored procedure like the following, with the bind variables ":start" and ":end" (the first item number and last item number of the search result page, respectively) being passed in from Java middle tier.
    select w.* from
    select v.*, rownum r from
    select * from MY_DOCUMENT where
    CONTAINS(content, 'some search words', 1) > 0
    order by score(1) desc
    ) v where rownum <= :end
    ) w where r >= :start
    It turns out that the "rownum" does not seem to be "deterministic", because if I assign ":start" = 1 and ":end = 1000", then I can see a particular document (say, it has a column ID = 2514) in the result set with rownum = 250. But if I set ":start" = 240 and ":end" = 260, then the document does not show up in that range.
    The worst thing is that if I my page size is 10, and when an end-user navigates from page 1 through page 10 (assume there are only 10 pages of results), some documents just never show up anywhere. In other words, if I call this stored procedure with (:start, :end) = (1, 10), (11, 20), (21, 30), ... (91, 100). Then a document which is obviously a match for the search does not show up any where. But I if I show all results in one page, i.e., set (:start, :end) = (1, 100), then I can see the document.
    Thanks for any help in advance!

    If you have a lot of matching scores, they may therefore be returned in any order. Have you tried adding ROWID to your order by clause, to ensure that each row has a unique order, like so?:
    select w.* from
    (select v.*, rownum r from
    (select * from MY_DOCUMENT where
    CONTAINS(content, 'some search words', 1) > 0
    order by score(1) desc, ROWID
    ) v where rownum <= :endnum
    ) w where r >= :startnum

  • Cannot find paged results cookie

    I have made an application, that works when accessing edirectory 8.8.2
    (on a windows server, not that the platform matters I suppose).
    I am able to do a paged ldap search, and my results are coming back to
    me, nice and paged, like they are supposed to.
    When I try the exact same code against a oes2sp1 with 8.8.4, I get
    something like this (and only the first page of results)
    (192.168.0.160:2151)(0x0003:0x63) controlPagedSetup: cannot find paged
    results cookie
    (192.168.0.160:2151)(0x0003:0x63) Sending operation result 53:"":"" to
    connection 0x6804380
    Why is the server saying that, and what does it mean? I don't recall
    any possibility of setting cookies in the ldap api (actually an delphi
    ldap control)

    I have found the Paged Results Control to work:
    http://ldapwiki.willeke.com/Wiki.jsp...deSortControls
    Not sure about 8.8.4 or using Netware as all my attempts are 8.8.2 &
    8.8.3 and on Linux/Unix.
    Send me an email: jim at willeke com and we can try some things.
    -jim
    Nicolai Jensen wrote:
    > I have made an application, that works when accessing edirectory 8.8.2
    > (on a windows server, not that the platform matters I suppose).
    > I am able to do a paged ldap search, and my results are coming back to
    > me, nice and paged, like they are supposed to.
    >
    > When I try the exact same code against a oes2sp1 with 8.8.4, I get
    > something like this (and only the first page of results)
    >
    > (192.168.0.160:2151)(0x0003:0x63) controlPagedSetup: cannot find paged
    > results cookie
    > (192.168.0.160:2151)(0x0003:0x63) Sending operation result 53:"":"" to
    > connection 0x6804380
    >
    > Why is the server saying that, and what does it mean? I don't recall
    > any possibility of setting cookies in the ldap api (actually an delphi
    > ldap control)
    >

  • Simple Paged Results Control

    ODSEE has everything I need in a directory server.
    One additional feature would make my day:
    Simple Paged Results Control
    We've got some pretty large containers on our directories, that not only cause the usual data warehouse type queries my developers like to do to fail (they keep bumping up against the entry return limit and allidsthreshold), but a real stressor on the directory server. I think I could convince them to use SPRC if it were available, as some of them have experience with Active Directory's implementation of it. Any chance we'll see this in future revs of ODSEE?

    Hi,
    You may want to consider Virtual List View (aka VLV Control) that provides result paging as well.
    More info at [http://docs.sun.com/app/docs/doc/821-1507/fpypa?l=all&a=view|http://docs.sun.com/app/docs/doc/821-1507/fpypa?l=all&a=view]
    Sylvain

  • Manuel php oracle en français

    est-ce que vous avez un manuel php oracle en français

    As this is english forum can you post your question in english please?
    French PHP documentation is here: http://www.php.net/manual/fr/ . Oracle functions and examples are included there.

Maybe you are looking for

  • Questions on HTML5 Output in FrameMaker 12

    I have a couple questions about the HTML5 Output: 1. I have images that are not appearing in the output (they are in the source FM file, but not in the HTML5 output). What am I doing wrong? 2. Is there a way to disable the glossary function so that i

  • PDF scanned by Epson v. Canon annotate by PDFPen (not)  viewable in Preview

    My question relates to the applications PDPen and Preview, and the scanners and scanning software of Epson and Canon. When I had an Epson print-scan-copy machine, I would scan originals into multi-page PDF files and I would page-number and annotate t

  • Sender SOAP Adapter Authentication issue

    All, We have a SOAP-XI-RFC scenario. We exported the wsdl from the Integration Directory. When we try to call the web service using webservice studio client. We get the following error. We are using a user that has (SAP_XI_ADMINISTRATOR role on it).

  • My Pound key is a hash tag

    On my keyboard my NO.3 key shows a pound sign above it............when I 'shift+3' I get a hash sign. How do I change this to a pound sign as showing on the key? thanks.

  • LSMW Conversion rules

    Hi guys, i want to upload Material Master QM view data with LSMW into ECC6.0 version server, before that i want to write the conversion rules... plz can any send the conversion code i have writen below... 1. If info record not maintained of vendor ma