Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法从MySQL中提取值_Php_Mysql_Docusignapi - Fatal编程技术网

Php 无法从MySQL中提取值

Php 无法从MySQL中提取值,php,mysql,docusignapi,Php,Mysql,Docusignapi,我的代码有问题。我创建了一个类来搜索作业id或任务id。但是我无法在MySQL中检索信封id。该值应为TESTTEST <?php class Envelope { private $_db, $_data; public function __construct($taskidorjobid = null, $taskid = null) { $this -> _db = DB::getInstance(); //$this ->

我的代码有问题。我创建了一个类来搜索作业id或任务id。但是我无法在MySQL中检索信封id。该值应为TESTTEST

<?php
class Envelope {
    private $_db, $_data;
    public function __construct($taskidorjobid = null, $taskid = null) {
        $this -> _db = DB::getInstance();
        //$this -> _sessionName = Config::get('session/session_name');
        //$this -> _cookieName = Config::get('remember/cookie_name');
        if ($taskidorjobid == null && $taskid == null) {

        } elseif ($taskid == null) {
            $this -> findtaskid($taskidorjobid);
        } else {
            $this -> find($taskidorjobid, $taskid);
        }
    }

    public function findtaskid($taskid = null) {
        if ($taskid) {
            $field = 'id';
            $data = $this -> _db -> get('task', array($field, '=', $taskid));
            if ($data -> count()) {
                $this -> _data = $data -> first();
                return true;
            }
        }
        return false;
    }

    public function find($jobid = null, $taskid = null) {
        if ($jobid and $taskid) {
            //$field = 'id';
            //$data = $this -> _db -> get('task', array($field, '=', $task));
            $data = $this -> _db -> query("select * from document where job = " . $jobid . " and taskid = " . $taskid);
            if ($data -> count()) {
                $this -> _data = $data -> first();
                return true;
            }
        }
        return false;
    }

    public function findenvelopeid($taskid = null, $version = null) {

            $sql = "select envelope_id from document where taskid = ?, version = ?, latestflag = ?";
            $param = array($taskid, $version, "yes");


            $data = $this-> _db->query($sql, $param);



       //foreach ($data->results() as $row) {
        if ($data -> count()) {
                $this -> _data = $data -> first();
                $envelope_id = $this -> _data -> envelope_id;
                return $envelope_id;

        }
        return false;

       }
}        
?>
然后在我的另一组php文件中,我调用了函数findenvelopeid,但它不返回任何值。我可以将$tid作为$taskid进行回显

$envelope = new Envelope();
$envelopeid = $envelope->findenvelopeid($tid,"signed_online");
echo "Envelope ID: ".$envelopeid. "<br>";
我的编码器开发的查询功能是:

public function query($sql,$params=array(), $options=array()){
    $this->_error=false;
    if($this->_query=$this->_pdo->prepare($sql)){
        $x=1;
        if(count($params)){
            foreach($params as $param){
                //if(count($options)>=$x){
                    //var_dump("DB sql: " . $sql . "<br/> x: " . $x . ", param: " . $param . ", options:" . $options[$x-1]);
                //   $this->_query->bindValue($x,$param, $options[$x-1]);
                //}else{
                    //var_dump("DB sql: " . $sql . "<br/> x: " . $x . ", param: " . $param);
                   $this->_query->bindValue($x,$param);
                //}
                $x++;
            }
        }
        if($this->_query->execute()){
            $this->_results=$this->_query->fetchAll(PDO::FETCH_OBJ);
            $this->_count=$this->_query->rowCount();
        }else{
            //var_dump("<br /> errorcode " . $this->_pdo->errorCode() . "<br />error info:");
            //print_r($this->_pdo->errorInfo());
            $this->_error=true;
        }
    }
    return $this;
}

请帮忙

哎呀,我应该在where子句中使用AND而不是a。

这有点乱。为什么$db=db::getInstance;当您的构造函数已经这样做并将其保存在$this->\u db上时,您已经知道,然后在方法代码中使用$this->\u db,如果您使用的是标记参数,即?您需要准备sql语句,然后->执行它,这真的很奇怪。因为我以前编写代码的程序员没有使用prepare和execute.like:public static函数getalldocumentsbytaskid$taskid{$db=db::getInstance;$documents=array;$sql=select*从taskid=?和latestflag=?;$param=array$taskid,是;$data=$db->query$sql,$param;//$data=$db->getdocument,ArrayTaskKid,=,$taskid;如果$data{foreach$data->结果为$row{$documents[]=新文档$row->id;}}返回$documents;}