Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 309895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:47:01+00:00 2026-05-12T07:47:01+00:00

Below is some example code of how I run my mysql queries, I run

  • 0

Below is some example code of how I run my mysql queries, I run them through a function which I think would maybe simpliy switching databases.

Below is an example of a mysql query I run and below that is the actual function.

Would it be difficult to change to a different database type like oracle or some other if I ever decided to using this setup?

Would be able to just modify the function or would I need to change the queries that are on every page?

$sql_photo = "select * from friend_user_photo  where userid='$user_id' and  defaultphoto='yes' order by auto_id desc";
$result_photo = executeQuery($sql_photo);

function executeQuery($sql) {
    $result = mysql_query_2($sql);
    if(mysql_error()){
         $error = '<BR><center><font size="+1" face="arial" color="red">An Internal Error has Occured.<BR> The error has been recorded for review</font></center><br>';
        // If admin is viewing then we show the query code and the error returned
        if($_SESSION['auto_id'] == 1){
           $sql_formatted = highlight_string( stripslashes( $sql ), true );
           $error .= '<b>The MySQL Syntax Used</b><br>' . $sql_formatted . '<br><br><b>The MySQL Error Returned</b><br>' . mysql_error() ;
        }
       die($error);
    }
    return $result;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:47:01+00:00Added an answer on May 12, 2026 at 7:47 am

    If you stick to pure non-proprietary (ANSI) SQL you won’t have to modify any queries. An example of where you might be using proprietary extensions is in pagination. If you’re doing any pagination within your web application it is highly likely that you’re using something like this:

    select id, name, created from thing limit(0,20)
    

    That query won’t work on Oracle, as limit is a proprietary extension to MySql, you would have to go about pagination using Oracle’s rownum (which can only take one argument), so essentially you will have to rewrite your pagination queries to look like this:

    select * 
      from ( select /*+ FIRST_ROWS(n) */ 
      a.*, ROWNUM rnum 
          from ( your_query_goes_here, 
          with order by ) a 
          where ROWNUM <= 
          :MAX_ROW_TO_FETCH ) 
    where rnum  >= :MIN_ROW_TO_FETCH;
    

    Also consider that you’ll be using one of the Oracle extensions, so your database connection, manipulation and error handling code will have to be rewritten too
    (example from the oci8 extension docs) and will look more like:

    if ($c = oci_connect("hr", "hr_password", "localhost/XE")) {
       echo "Successfully connected to Oracle.";
       oci_close($c);
     } else {
       $err = oci_error();
       echo "Oracle Connect Error " . $err['text'];
     }
       // Select Data...
       $s = oci_parse($c, "select * from tab1");
       oci_execute($s, OCI_DEFAULT);
       while (oci_fetch($s)) {
         echo "COL1 = " . oci_result($s, "COL1") .
            ", COL2 = " . oci_result($s, "COL2") . "<br>\n";
       }
    

    So as you can see it is no trivial feat, especially not if you have tons of MySql-hardwired code.

    If the portability of your application is a major concern you should seriously consider using a library that allows you to abstract out the database vendor altogether. I use Zend_Db (which incidentally supports Oracle) but there are others out there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the code below I'm trying to load some images and put them in
For some reason I'm not getting this. (Example model below) If I write: var
Note The question below was asked in 2008 about some code from 2003. As
See code below, for some reason it only works when I put a breakpoint
UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
in the code below i want to implement the floyd algorithm,the user enter some
I've been using the idiom below for some time now. And it seems to
I have an xslt sheet with some text similar to below: <xsl:text>I am some
Some batch files on Windows use an IF syntax with multiple lines, as below:
I've just started with opengl but I ran into some strange behaviour. Below I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.