Results 1 to 6 of 6

Thread: วิธีการเชื่อมต่อฐานข้อมูล Oracle โดยใช้ PHP

  1. #1
    Jedi Global Moderator
    Join Date
    Aug 2007
    Location
    Bangkok
    Posts
    136


    แหล่งที่มา http://www.oracle.com/technology/pub/notes...hp_instant.html
    Enabling the PHP OCI8 Extension on Windows

    The Instant Client binaries complement PHP's prebuilt binaries for Windows.

    1. Download the PHP binary zip file (not the installer build) and Apache. Install them following Installation on Windows Systems in the PHP Manual. OTN's PHP Developer Center contains links to useful background material such as "Installing Oracle, PHP, and Apache on Windows 2000/XP," which covers installation of a traditional, full Oracle 10g footprint (which is not required with Instant Client).

    Check that PHP is working before continuing. At this stage Oracle support is not enabled.
    2. Download the Instant Client Basic package for Windows from the Instant Client page on OTN. The zip file is about 30MB in size.
    3. Create a subdirectory (e.g., c:\instantclient10_1) and copy these libraries from the zip file:
    * oraociei10.dll
    * orannzsbb10.dll
    * oci.dll

    Collectively these three files are about 80MB in size.

    To use PHP's older "oracle" extension (enabled with "extension=php_oracle.dll" in php.ini), copy ociw32.dll instead of oci.dll.
    4. Edit the environment and add c:\instantclient10_1 to PATH before any other Oracle directories.

    For example, on Windows 2000, follow Start -> Settings -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.

    If a tnsnames.ora file is used to define Oracle Net service names, copy tnsnames.ora to c:\instantclient10_1 and set the user environment variable TNS_ADMIN to c:\instantclient10_1. A default service name can optionally be set in the user environment variable LOCAL.

    Set necessary Oracle globalization language environment variables such as NLS_LANG. If nothing is set, a default local environment will be assumed. See An Overview on Globalizing Oracle PHP Applications for more details.

    Unset unnecessary Oracle variables such as ORACLE_HOME and ORACLE_SID.
    5. Edit php.ini and uncomment the OCI8 extension:

    extension=php_oci8.dll

    Set the extension_dir directive to the full PHP extension DLL path. In PHP 4 the DLLs are in the "extensions" sub-directory of the PHP software. In PHP 5 they are in "ext".
    6. Restart Apache.
    To check the extension is configured, create a simple PHP script phpinfo.php where the web server can read it.

    <?php
    phpinfo();
    ?>
    เนื่องจากช่วงนี้ ผมต้องเีขียน PHP เพื่อเชื่อมต่อกับ Database Oracle หาวิธีอยู่ 2 วันกว่าจะได้ เลยถือโอกาส ทำมาเป็นภาษาไทย เอามาแบ่งปันกันครับ
    เข้าไปอ่านวิธีการ ได้ตาม link ข้างบนนะครับ สำหรับคนที่ไม่เชี่ยวชาญภาษาอังกฤษ ผมทำเป็นคู่มือภาษาไทย ให้แล้วนะครับ
    download ได้ที่ นี่ครับ
    **Hidden Content: To see this hidden content your post count must be 5 or greater.**

  2. #2
    Junior Member
    Join Date
    Jul 2008
    Location
    Bangkok
    Posts
    14


    ใช้ oracle ทำไมม่ะใช้ jsp ล่ะคับ... หรือว่ามีความจำเป็นที่ต้องใช้ php

    ใช้แล้วเวิร์กมั้ย ? คับ ...

    เห็นเพื่อนผมใช้ PL/SQL เป็นตัวที่ติดมากับ oracle เห็นว่าเวิร์กดี ...

    แต่ม่ะแน่ใจ ว่า PL/SQL จะประยุกต์รันผ่าน web browser ได้หรือเปล่า ....

    เสริมน่ะคับ แหล่ง ดาว์นโหลด ORACLE

    **Hidden Content: To see this hidden content your post count must be 2 or greater.**

  3. #3
    Jedi Global Moderator
    Join Date
    Aug 2007
    Location
    Bangkok
    Posts
    136


    ภาษาที่ใช้ในการพัฒนาโปรแกรม บางครั้งมันขึ้นอยู่กับอะไรหลายๆ อย่างที่ใช้ในองค์กร เริ่มตั้งแต่ OS , Database และการวางโครงสร้าง Network ในองค์กรด้วย
    สำหรับองค์กรที่ผมทำงานอยู่นั้น มีฐานข้อมูลหลักเป็น Oracle อยู่แล้ว ที่ Run บน OS Windows 2000 ในขณะที่ Web Site ตัวเิดิมขององค์กร พัฒนาด้วย ภาษา PHP ทีนี้ ทางเลือกมี 3 ทาง ที่คิดได้
    1. ตั้ง Server ขึ้นมาใหม่ เพื่อให้สามารถรองรับ ภาษา Java แล้วเขียน Web ด้วย Jsp ไปดึงข้อมูลใน Oracle
    2. ใช้ PHP เขียน Web แล้วเลือก Database เป็น MySQL เพราะเหมาะกับ PHP แล้วเวลาจะดึงข้อมูลที ก็ต้อง generate เป็น SQL Command เพื่อจะมา Run บน MySQL ทุกวันอย่างนั้นหรือ
    3. ใช้ PHP เขียน Web แล้วต่อกับฐานข้อมูล Oracle โดยตรง

    ผมเลือกข้อ 3 เพราะเมื่อต่อฐรนข้อมูล Oracle โดย PHP ได้แล้ว ผมสามารถ เรียก PL/SQL สามารถใช้งาน Function ที่มีอยู่แล้วใน Oracle โดยไม่ต้องเขียนใหม่ รวมทั้งสามารถดึงข้อมูลที่มีอยู่บน Oracle มาได้โดยตรง รวมทั้งไม่ต้องไปลง Java หรือทำ Server ที่เป็น Java Platform ขึ้นมาใหม่ เืพื่อจะเขียน Application เล็ก แต่ต้องให้ Admin มาดูแล Server ที่เป็น Java อีกทีหนึ่ง
    ข้อ 1 ต้องมีคนดูแล Server ทั้งๆ ที่ต้องการแค่ Web Application เล็กตัวหนึ่ง ดังนั้นจึงไม่เหมาะกับการใช้งาน
    ข้อ 2 ถ้าใช้ PHP ต่อกับ MySQL ซึ่งทำได้สะดวก แต่ต้องมา Generate ข้อมูล เพื่อ Insert ข้าม DB แถมดึงข้อมูลไม่ได้โดยตรง จึงตัดไป
    ข้อ 3 เป็นวิธีที่ดีที่สุด เท่าที่คิดได้ ไม่ต้องเขียน PL/SQL ใหม่ และสามารถใช้ user และ pass ของระบบเดิม จึงเลือกข้อนี้ครับ

  4. #4


    เยี่ยมครับ ผมเคยหาวิธีอยู่เหมือนกัน

    หา function oci ไม่เจอซักที ผลสุดท้ายเลยต้องเอา XAMPP มาใช้

    ลงปุ๊บก็ยังใช้ไม่ได้ ทำไปทำมา เป็นที่ version ORACLE นั่นเอง
    <div align="center">[url="http://twitter.com/hyde4fun"][img]http://feelza.net/tweetsig/img/hyde4fun.png[/img][/url]</div>

  5. #5
    Jedi Global Moderator
    Join Date
    Aug 2007
    Location
    Bangkok
    Posts
    136


    ตอนแรกที่ผมทำแล้วมัน connect DB ของ Oracle ผมก็สงสัยเหมือนกันว่าทำไมมันไม่ได้ซักที พอไปอ่านตามรายละเอียดของ
    link แหล่งที่มา http://www.oracle.com/technology/pub...p_instant.html ผมถึงเข้าใจว่าทำไมต้อง load ตัว
    instantclient10_1 มาเพราะ Oracle ตัวที่ผมใช้อยู่ version 8.1.17 ผมลอง เปลี่ยน configuration ไปใช้ oci.dll ตาม Path ของ Oracle Version 8.1.17 ที่มีอยู่ในเครื่องก็ connection ไม่ได้ มันจะขึ้นว่าหา oci.dll ไม่เจอ
    ข้อสรุปที่ผมคิดไว้คือ ต้องใช้ instantclient10_1 ตามที่ download มาแล้วตั้งตามที่ Web Site ของ Oracle แนะนำ และสามารถใช้ได้ครับ กับ Version ที่สูงขึ้น ทุก Version ไม่ว่าจะเป็น Oracle Version 10 หรือ 11 ครับ

  6. #6
    Junior Member
    Join Date
    Jun 2009
    Posts
    10


    ขอบคุณมากเลยครับ ตอนนี้ผมก็กำลังศึกษาการติดต่อฐานข้อมูล Oracle โดยใช้ PHP


    ผมก็มี การติดต่อใช้งาน Oracle Database ด้วย PHP เพิ่มเติ่มครับ

    **Hidden Content: To see this hidden content your post count must be 5 or greater.**


Similar Threads

  1. วิธีโหลดหนังจาก mthai โดยใช้ idm
    By rayanddaw in forum Computer Tip & Trick / Tutorial
    Replies: 3
    Last Post: 01-07-2009, 08:20 PM
  2. Replies: 11
    Last Post: 19-09-2007, 02:49 AM
  3. Replies: 0
    Last Post: 07-09-2007, 07:22 PM
  4. การทำ RAID 0 โดยใช้ Windows XP
    By mamomuma in forum Computer Tip & Trick / Tutorial
    Replies: 0
    Last Post: 18-07-2007, 11:31 AM
  5. Replies: 0
    Last Post: 27-03-2003, 01:59 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •