Skip to content

Instantly share code, notes, and snippets.

@odan
Last active May 30, 2024 21:28
Show Gist options
  • Select an option

  • Save odan/4edb46a44721f2ef3bdefe2ea999e2e8 to your computer and use it in GitHub Desktop.

Select an option

Save odan/4edb46a44721f2ef3bdefe2ea999e2e8 to your computer and use it in GitHub Desktop.

Revisions

  1. odan revised this gist Nov 18, 2018. 1 changed file with 1 addition and 103 deletions.
    104 changes: 1 addition & 103 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -1,105 +1,3 @@
    # XAMPP - Oracle Driver Setup (v12)

    ## Requirements

    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer the x86 **AND** the x64 version must be installed.

    [Visual C++ Redistributable für Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)

    ## Setup

    Testest with PHP 5.6, 7.0, 7.1, 7.2

    * Download the Oracle Instant Client for Microsoft Windows (32-bit) v.12
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    * Unzip file: `instantclient-basiclite-nt-12.2.0.1.0.zip`
    * Copy all *.dll files: to `c:\xampp\php`
    * Copy all *.dll files to `c:\xampp\apache\bin` (Yes, a second copy!)
    * Make sure that the file `c:\xampp\php\ext\php_oci8_12c.dll` exists.
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll` (For PHP 7.2+ use `extension=oci8_12c`)
    * Restart Apache
    * Click the Github ★ Star button :-)

    ## Known issues

    Especially the `WAMP` users reported that they still get the following error message:

    `PHP Warning: PHP Startup: Unable to load dynamic library 'oci8_12c'`.

    In this case try to download the correct dll files from this link:

    * http://windows.php.net/downloads/pecl/releases/oci8/2.1.8 -> php_oci8-2.1.8-7.2-ts-vc15-x86.zip

    ## Connection test
    ```php
    <?php

    error_reporting(E_ALL);

    if (function_exists("oci_connect")) {
    echo "oci_connect found\n";
    } else {
    echo "oci_connect not found\n";
    exit;
    }

    $host = 'localhost';
    $port = '1521';

    // Oracle service name (instance)
    $db_name = 'DBNAME';
    $db_username = "USERNAME";
    $db_password = "123456";

    $tns = "(DESCRIPTION =
    (CONNECT_TIMEOUT=3)(RETRY_COUNT=0)
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = $host)(PORT = $port))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = $db_name)
    )
    )";
    $tns = "$host:$port/$db_name";

    try {
    $conn = oci_connect($db_username, $db_password, $tns);
    if (!$conn) {
    $e = oci_error();
    throw new Exception($e['message']);
    }
    echo "Connection OK\n";

    $stid = oci_parse($conn, 'SELECT * FROM ALL_TABLES');

    if (!$stid) {
    $e = oci_error($conn);
    throw new Exception($e['message']);
    }
    // Perform the logic of the query
    $r = oci_execute($stid);
    if (!$r) {
    $e = oci_error($stid);
    throw new Exception($e['message']);
    }

    // Fetch the results of the query
    while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
    $row = array_change_key_case($row, CASE_LOWER);
    print_r($row);
    break;
    }

    // Close statement
    oci_free_statement($stid);

    // Disconnect
    oci_close($conn);

    }
    catch (Exception $e) {
    print_r($e);
    }
    ```

    More infos: https://blogs.oracle.com/opal/installing-xampp-for-php-and-oracle-database
    The url has changed: https://odan.github.io/2017/03/21/xampp-oracle-driver-setup-v12.html
  2. odan revised this gist Apr 27, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,16 @@ Testest with PHP 5.6, 7.0, 7.1, 7.2
    * Restart Apache
    * Click the Github &#9733; Star button :-)

    ## Known issues

    Especially the `WAMP` users reported that they still get the following error message:

    `PHP Warning: PHP Startup: Unable to load dynamic library 'oci8_12c'`.

    In this case try to download the correct dll files from this link:

    * http://windows.php.net/downloads/pecl/releases/oci8/2.1.8 -> php_oci8-2.1.8-7.2-ts-vc15-x86.zip

    ## Connection test
    ```php
    <?php
  3. odan revised this gist Apr 22, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@ Testest with PHP 5.6, 7.0, 7.1, 7.2
    * Unzip file: `instantclient-basiclite-nt-12.2.0.1.0.zip`
    * Copy all *.dll files: to `c:\xampp\php`
    * Copy all *.dll files to `c:\xampp\apache\bin` (Yes, a second copy!)
    * Make sure that the file `c:\xampp\php\ext\php_oci8_12c.dll` exists.
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll` (For PHP 7.2+ use `extension=oci8_12c`)
    * Restart Apache
    * Click the Github &#9733; Star button :-)
  4. odan revised this gist Apr 22, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ Testest with PHP 5.6, 7.0, 7.1, 7.2
    * Unzip file: `instantclient-basiclite-nt-12.2.0.1.0.zip`
    * Copy all *.dll files: to `c:\xampp\php`
    * Copy all *.dll files to `c:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll` (For PHP 7.2+ use `extension=oci8_12c`)
    * Restart Apache
    * Click the Github &#9733; Star button :-)

  5. odan revised this gist Mar 2, 2018. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,7 @@

    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer the x86 **AND** the x64 version must be installed.

    Here are the required dependencies for the PHP extension: `php_oci8_12c.dll`

    * PHP 7.2: [Visual C++ Redistributable für Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)
    [Visual C++ Redistributable für Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)

    ## Setup

  6. odan revised this gist Mar 2, 2018. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,9 @@

    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer the x86 **AND** the x64 version must be installed.

    * PHP 5.6: The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 [x86 or x64](http://www.microsoft.com/en-us/download/details.aspx?id=30679) installed

    * PHP 7.0.x, 7.1.x: The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 [x86 or x64](http://www.microsoft.com/en-us/download/details.aspx?id=48145) installed

    * PHP 7.2.x: The VC15 builds require to have the Visual C++ Redistributable for Visual Studio 2017 [x64](https://go.microsoft.com/fwlink/?LinkId=746572) or [x86](https://go.microsoft.com/fwlink/?LinkId=746571) installed
    Here are the required dependencies for the PHP extension: `php_oci8_12c.dll`

    * PHP 7.2: [Visual C++ Redistributable für Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=52685)

    ## Setup

  7. odan revised this gist Mar 1, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ Testest with PHP 5.6, 7.0, 7.1, 7.2
    * Copy all *.dll files to `c:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github &#9733; Star :-)
    * Click the Github &#9733; Star button :-)

    ## Connection test
    ```php
  8. odan revised this gist Mar 1, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## Requirements

    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer should install the x86 **AND** the x64 version.
    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer the x86 **AND** the x64 version must be installed.

    * PHP 5.6: The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 [x86 or x64](http://www.microsoft.com/en-us/download/details.aspx?id=30679) installed

  9. odan revised this gist Mar 1, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    ## Requirements

    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition.
    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Notice: On a x64 computer should install the x86 **AND** the x64 version.

    * PHP 5.6: The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 [x86 or x64](http://www.microsoft.com/en-us/download/details.aspx?id=30679) installed

  10. odan revised this gist Mar 1, 2018. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,19 @@
    # XAMPP - Oracle Driver Setup (v12)

    ## Requirements

    This driver requires the Microsoft Visual C++ Redistributable. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition.

    * PHP 5.6: The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 [x86 or x64](http://www.microsoft.com/en-us/download/details.aspx?id=30679) installed

    * PHP 7.0.x, 7.1.x: The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 [x86 or x64](http://www.microsoft.com/en-us/download/details.aspx?id=48145) installed

    * PHP 7.2.x: The VC15 builds require to have the Visual C++ Redistributable for Visual Studio 2017 [x64](https://go.microsoft.com/fwlink/?LinkId=746572) or [x86](https://go.microsoft.com/fwlink/?LinkId=746571) installed


    ## Setup

    Testest with PHP 5.6, 7.0, 7.1.
    Testest with PHP 5.6, 7.0, 7.1, 7.2

    * Download the Oracle Instant Client for Microsoft Windows (32-bit) v.12
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
  11. odan revised this gist Mar 1, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -83,4 +83,6 @@ try {
    catch (Exception $e) {
    print_r($e);
    }
    ```
    ```

    More infos: https://blogs.oracle.com/opal/installing-xampp-for-php-and-oracle-database
  12. odan revised this gist Jun 14, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -7,8 +7,8 @@ Testest with PHP 5.6, 7.0, 7.1.
    * Download the Oracle Instant Client for Microsoft Windows (32-bit) v.12
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    * Unzip file: `instantclient-basiclite-nt-12.2.0.1.0.zip`
    * Copy files: `oci.dll`, `oraociicus12.dll`, `oraons.dll` to `c:\xampp\php`
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Copy all *.dll files: to `c:\xampp\php`
    * Copy all *.dll files to `c:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github &#9733; Star :-)
  13. odan revised this gist Mar 21, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Testest with PHP 5.6, 7.0, 7.1.
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github `&#9733; Star` :-)
    * Click at the Github &#9733; Star :-)

    ## Connection test
    ```php
  14. odan revised this gist Mar 21, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Testest with PHP 5.6, 7.0, 7.1.
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github &#9733; :-)
    * Click at the Github `&#9733; Star` :-)

    ## Connection test
    ```php
  15. odan revised this gist Mar 21, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Testest with PHP 5.6, 7.0, 7.1.
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github star :-)
    * Click at the Github &#9733; :-)

    ## Connection test
    ```php
  16. odan revised this gist Mar 21, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Testest with PHP 5.6, 7.0, 7.1.
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github star
    * Click at the Github star :-)

    ## Connection test
    ```php
  17. odan revised this gist Mar 21, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ Testest with PHP 5.6, 7.0, 7.1.
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache
    * Click at the Github star

    ## Connection test
    ```php
  18. odan revised this gist Mar 21, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,6 @@ Testest with PHP 5.6, 7.0, 7.1.

    * Download the Oracle Instant Client for Microsoft Windows (32-bit) v.12
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    http://download.oracle.com/otn/nt/instantclient/121020/instantclient-basiclite-nt-12.1.0.2.0.zip
    * Unzip file: `instantclient-basiclite-nt-12.2.0.1.0.zip`
    * Copy files: `oci.dll`, `oraociicus12.dll`, `oraons.dll` to `c:\xampp\php`
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
  19. odan revised this gist Mar 21, 2017. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -4,16 +4,15 @@

    Testest with PHP 5.6, 7.0, 7.1.

    * Download Oracle Instant Client for Microsoft Windows (32-bit) v.12
    * Download the Oracle Instant Client for Microsoft Windows (32-bit) v.12
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    http://download.oracle.com/otn/nt/instantclient/121020/instantclient-basiclite-nt-12.1.0.2.0.zip
    * Unzip file: instantclient-basiclite-nt-12.2.0.1.0.zip
    * Unzip file: `instantclient-basiclite-nt-12.2.0.1.0.zip`
    * Copy files: `oci.dll`, `oraociicus12.dll`, `oraons.dll` to `c:\xampp\php`
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension php.ini: extension=php_oci8_12c.dll
    * Enable php extension in php.ini: `extension=php_oci8_12c.dll`
    * Restart Apache


    ## Connection test
    ```php
    <?php
  20. odan revised this gist Mar 21, 2017. 1 changed file with 39 additions and 38 deletions.
    77 changes: 39 additions & 38 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -21,17 +21,17 @@ Testest with PHP 5.6, 7.0, 7.1.
    error_reporting(E_ALL);

    if (function_exists("oci_connect")) {
    echo "oci_connect found\n";
    echo "oci_connect found\n";
    } else {
    echo "oci_connect not found\n";
    exit;
    echo "oci_connect not found\n";
    exit;
    }

    $host = 'localhost';
    $port = '1521';

    // Oracle service name (instance)
    $db_name = 'DBNAME';
    $db_name = 'DBNAME';
    $db_username = "USERNAME";
    $db_password = "123456";

    @@ -47,40 +47,41 @@ $tns = "(DESCRIPTION =
    $tns = "$host:$port/$db_name";

    try {
    $conn = oci_connect($db_username, $db_password, $tns);
    if (!$conn) {
    $e = oci_error();
    throw new Exception($e['message']);
    }
    echo "Connection OK\n";

    $stid = oci_parse($conn, 'SELECT * FROM ALL_TABLES');

    if (!$stid) {
    $e = oci_error($conn);
    throw new Exception($e['message']);
    }
    // Perform the logic of the query
    $r = oci_execute($stid);
    if (!$r) {
    $e = oci_error($stid);
    throw new Exception($e['message']);
    }

    // Fetch the results of the query
    while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
    $row = array_change_key_case($row, CASE_LOWER);
    print_r($row);
    break;
    }
    $conn = oci_connect($db_username, $db_password, $tns);
    if (!$conn) {
    $e = oci_error();
    throw new Exception($e['message']);
    }
    echo "Connection OK\n";

    // Close statement
    oci_free_statement($stid);

    // Disconnect
    oci_close($conn);

    } catch (Exception $e) {
    print_r($e);
    $stid = oci_parse($conn, 'SELECT * FROM ALL_TABLES');

    if (!$stid) {
    $e = oci_error($conn);
    throw new Exception($e['message']);
    }
    // Perform the logic of the query
    $r = oci_execute($stid);
    if (!$r) {
    $e = oci_error($stid);
    throw new Exception($e['message']);
    }

    // Fetch the results of the query
    while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
    $row = array_change_key_case($row, CASE_LOWER);
    print_r($row);
    break;
    }

    // Close statement
    oci_free_statement($stid);

    // Disconnect
    oci_close($conn);

    }
    catch (Exception $e) {
    print_r($e);
    }
    ```
  21. odan revised this gist Mar 21, 2017. 1 changed file with 67 additions and 1 deletion.
    68 changes: 67 additions & 1 deletion php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,71 @@ Testest with PHP 5.6, 7.0, 7.1.

    ## Connection test
    ```php
    todo
    <?php

    error_reporting(E_ALL);

    if (function_exists("oci_connect")) {
    echo "oci_connect found\n";
    } else {
    echo "oci_connect not found\n";
    exit;
    }

    $host = 'localhost';
    $port = '1521';

    // Oracle service name (instance)
    $db_name = 'DBNAME';
    $db_username = "USERNAME";
    $db_password = "123456";

    $tns = "(DESCRIPTION =
    (CONNECT_TIMEOUT=3)(RETRY_COUNT=0)
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = $host)(PORT = $port))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = $db_name)
    )
    )";
    $tns = "$host:$port/$db_name";

    try {
    $conn = oci_connect($db_username, $db_password, $tns);
    if (!$conn) {
    $e = oci_error();
    throw new Exception($e['message']);
    }
    echo "Connection OK\n";

    $stid = oci_parse($conn, 'SELECT * FROM ALL_TABLES');

    if (!$stid) {
    $e = oci_error($conn);
    throw new Exception($e['message']);
    }
    // Perform the logic of the query
    $r = oci_execute($stid);
    if (!$r) {
    $e = oci_error($stid);
    throw new Exception($e['message']);
    }

    // Fetch the results of the query
    while ($row = oci_fetch_array($stid, OCI_ASSOC + OCI_RETURN_NULLS)) {
    $row = array_change_key_case($row, CASE_LOWER);
    print_r($row);
    break;
    }

    // Close statement
    oci_free_statement($stid);

    // Disconnect
    oci_close($conn);

    } catch (Exception $e) {
    print_r($e);
    }
    ```
  22. odan created this gist Mar 21, 2017.
    20 changes: 20 additions & 0 deletions php-oracle.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # XAMPP - Oracle Driver Setup (v12)

    ## Setup

    Testest with PHP 5.6, 7.0, 7.1.

    * Download Oracle Instant Client for Microsoft Windows (32-bit) v.12
    http://www.oracle.com/technetwork/topics/winsoft-085727.html
    http://download.oracle.com/otn/nt/instantclient/121020/instantclient-basiclite-nt-12.1.0.2.0.zip
    * Unzip file: instantclient-basiclite-nt-12.2.0.1.0.zip
    * Copy files: `oci.dll`, `oraociicus12.dll`, `oraons.dll` to `c:\xampp\php`
    * Copy file: `oci.dll` to `C:\xampp\apache\bin` (Yes, a second copy!)
    * Enable php extension php.ini: extension=php_oci8_12c.dll
    * Restart Apache


    ## Connection test
    ```php
    todo
    ```