0

I've started a project where the user can either connect to a mySQL database or an oracle database. I got the mySQL part down but oracle is being a bit difficult. Standard queries work such as SELECT * FROM author, but when I try to load a script in order to create the schema I get invalid operation errors. I've tried using 'START' and '@' in various ways but to no avail. These commands work in the command line but not in php. I've tried the following:

else if($databaseType == "Oracle")
{
$c = oci_connect($username, $password, $server);
     if (!$c) {
       echo "Unable to connect: " . var_dump( oci_error() );
       die();
     }


    // Delete previous schema
    $s = oci_parse($c, "@/oracle/dropall");
    oci_execute($s, OCI_DEFAULT);

    // Create schema
    $s = oci_parse($c, "@/oracle/oracle");
    oci_execute($s, OCI_DEFAULT);

    // Create first trigger
    $s = oci_parse($c, "@/oracle/oracle_trigger1");
    oci_execute($s, OCI_DEFAULT);

    // Create second trigger
    $s = oci_parse($c, "@/oracle/oracle_trigger2");
    oci_execute($s, OCI_DEFAULT);

    // Populate the database
    $s = oci_parse($c, "@/oracle/oracle_populate");
    oci_execute($s, OCI_DEFAULT);


    // Commit to save changes...
    oci_commit($c);

    // Logoff from Oracle...
    oci_free_statement($s);
    oci_close($c);
}

1 Answer 1

1

OCI_PARSE

resource oci_parse ( resource $connection , string $sql_text )

It expecting a SQL statement instead of file name.

You want to try:

 $s = oci_parse($c, file_get_contents('/oracle/dropall'));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.