0

I dont know where my mistake is but i want to store an oracle query inside a function and return that function inside an array.

JobDrop.php

class JobDrop {
    private $jobSql = "SELECT VMI.PROJECT_NO JOB FROM VW_MTO_INFO VMI ORDER BY VMI.PROJECT_NO ASC";

    function _construct($jobSql){
        $this->jobSql = $jobSql;
    }

    function JobDropdown($conn){
        $jobParse = oci_parse($conn, $this->jobSql);
        $jobExcErr = oci_execute($jobParse);

        if (!$jobExcErr){
            $e = oci_error($jobParse);
                print htmlentities($e['message']);
                print "\n<pre>\n";
                print htmlentities($e['sqltext']);
                printf("\n%".($e['offset']+1)."s", "^");
                print  "\n</pre>\n";
        } else {

            $res = array();
            while ($row = oci_fetch_assoc($jobParse)){
                $res[] = $row;
            } 
            $listVendor = json_encode($res, JSON_PRETTY_PRINT);

            return $listVendor;
        }


}
    }

and in test.php

include './job_drop.php';
require_once('../../lib/dbinfo.inc.php');
$conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);


$jobdrop = new JobDrop();

$jobdrop->JobDropdown($conn);
var_dump($jobdrop);

but it doesnt show the array inside the browser. it shows the query string instead,

object(JobDrop)#1 (1) { ["jobSql":"JobDrop":private]=> string(74) "SELECT VMI.PROJECT_NO JOB FROM VW_MTO_INFO VMI ORDER BY VMI.PROJECT_NO ASC" } 

Please help me where I am doing wrong here

1
  • 1
    Are you saying you want to save the results of the query in the JobDrop class? As you have it now, you are not capturing the return value of JobDropdown function. Commented Oct 26, 2015 at 5:13

1 Answer 1

1

If you want to see the array, do:

$res = $jobdrop->JobDropdown($conn);
var_dump($res);
Sign up to request clarification or add additional context in comments.

2 Comments

This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
@IanKemp: the author's post identifies but it doesnt show the array inside the browser. it shows the query string instead as the proximate issue for which help is being requested. My answer addresses that.

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.