如何从php调用oracle函数

时间:2018-04-04 14:01:58

标签: php oracle function

任何人都可以指导我如何在php中调用oracle函数吗?

我正在研究基于CRUD的Web应用程序,这是我迄今为止所做的。

<div class="container">
    <div class="panel panel-default">
        <div class="panel-body">
    <div id="addroles" class="hide" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <div id="resultActivityContent"></div>
    </div>  
    <form class="cmxform" id="addroles">
        <legend>Add Roles</legend>
        <label for="names">Select Name</label>
        <select class="form-control" name="names" id="names">
           <option selected disabled></option>
           <?php 
           $dbUser = "";
            $dbPass = "";
            $dbConn = "(DESCRIPTION = (ADDRESS = (PROTOCOL=TCP)(HOST=  )(PORT=  ))(CONNECT_DATA=(SID=  )))"; 
            $conn = oci_connect($dbUser, $dbPass, $dbConn);
            $sql = oci_parse($conn, "SELECT PERSON.FNAME, PERSON.LNAME FROM PERSON");
            oci_execute($sql, OCI_DEFAULT);
            ?>
           <?php
              while (oci_fetch($sql))
                  { ?>
                echo '<option value="<?php echo oci_result($sql, 'FNAME', 'LNAME')?>"><?=oci_result($sql,'FNAME') ?><?=oci_result($sql,'LNAME') ?></option>  
            <?php   
        }?>
        </select>   
        <br>
        <br>
        <label for="role">Select Role</label>
         <select class="form-control" name="role" id="role">
           <option selected disabled></option>
           <?php 
           $dbUser = "  ";
            $dbPass = "  ";
            $dbConn = "(DESCRIPTION = (ADDRESS = (PROTOCOL=TCP)(HOST=  )(PORT=  ))(CONNECT_DATA=(SID=  )))"; 
            $conn = oci_connect($dbUser, $dbPass, $dbConn);
            $sql = oci_parse($conn, "SELECT ROLE.ROLEDESC FROM ROLE");
            oci_execute($sql, OCI_DEFAULT);
            ?>
           <?php
              while (oci_fetch($sql))
                  { ?>
                echo '<option value="<?php echo oci_result($sql, 'ROLEDESC')?>"><?=oci_result($sql,'ROLEDESC') ?></option>  
            <?php   
        }?>

        </select> 
        <br>
        <button class="btn btn-info btn-primary" type="submit">Add Role</button>
        <br>
        <br>
    </form>
            </div>
     </div>       
</div>

正如您现在所看到的,所有内容都在同一个文件中,因此我想单独编写 用于连接的文件和用于函数的另一个文件,并调用相应的函数 这个档案。

0 个答案:

没有答案