Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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 NOTORM连接返回null_Php_Mysql_Join_Notorm - Fatal编程技术网

Php NOTORM连接返回null

Php NOTORM连接返回null,php,mysql,join,notorm,Php,Mysql,Join,Notorm,我的Slim-Rest-API遇到了一个问题,剩下的就是我头上的问号 我在API中加入了几个allready表,这些表运行良好: // Detail View of Task $app->get('/task_detail/:id', function($id) use ($app, $db) { $task_data_array = array(); foreach ($db->task()->where('task_id', $id) as $task) {

我的Slim-Rest-API遇到了一个问题,剩下的就是我头上的问号

我在API中加入了几个allready表,这些表运行良好:

// Detail View of Task
$app->get('/task_detail/:id', function($id) use ($app, $db) {
    $task_data_array = array();
    foreach ($db->task()->where('task_id', $id) as $task) {
        $task_data_array[] = array(
            'task_id' => $task['task_id'],
            'task_date' => $task['task_date'],
            'task_deadline' => $task['task_deadline'],
            'target_snr' => $task['target_snr'],
            'client_name' => $task->client['client_name'],
            'client_adress' => $task->client['client_adress'],
            'client_zip' => $task->client['client_zip'],
            'client_contact' => $task->client['client_contact'],
            'workflow_id' => $task['workflow_id'],
            'task_type' => $task->task_type['task_type'],
            'task_desc' => $task->task_type['task_desc'],
            'status' => $task['status']
            );
    }
    $app->response()->header('Content-Type', 'application/json;charset=utf-8');
    echo json_encode($task_data_array);
});
返回:

[{"task_id":"1","task_date":"2016-06-15","task_deadline":"2016-06-30 11:00:00.000000","target_snr":"12523452343","client_name":"Stahlbau AG","client_adress":"Stahlbruch 40","client_zip":"48881","client_contact":"stahl@stahlbauag.de","workflow_id":"1","task_type":"blabla","task_desc":"blabla","status":"Open"}]
在这里,我将任务表与客户机和任务类型表连接起来。它工作得很好

但是:

现在我得到了两个示例,其中联接不起作用,只返回“null”作为联接值:

代码:

返回:

[{"workflow_id":"2","workflow_name":"Reparatur","workflow_desc":"blabla","product_id":"2","product_type":null,"product_name":null,"list_category_id":"1004","list_category_desc":"Hardware-Tausch"}]
[{"task_id":"1","list_catalog_id":"11","list_catalog_task":"Akku Aufschrauben","list_catalog_desc":"Akkufach aufschrauben. Dafuer 13 Schrauben entfernen blabla","task_date":null,"target_snr":null}]
我在另一个问题上遇到了同样的问题:

$app->get('/task_solution/:id', function($id) use ($app, $db) {
    $solution_array = array();
    foreach ($db->task_list_solution()->where('task_id',$id) as $solution) {
        $solution_array[] = array(
            'task_id' => $solution['task_id'],
            'list_catalog_id' => $solution['list_catalog_id'],
            'list_catalog_task' => $solution->list_catalog['list_catalog_task'],
            'list_catalog_desc' => $solution->list_catalog['list_catalog_desc'],
            'task_date' => $solution->task['task_date'],
            'target_snr' => $solution->task['target_snr']
            );
        $app->response()->header('Content-Type', 'application/json;charset=utf-8');
        echo json_encode($solution_array);
    }
});
返回:

[{"workflow_id":"2","workflow_name":"Reparatur","workflow_desc":"blabla","product_id":"2","product_type":null,"product_name":null,"list_category_id":"1004","list_category_desc":"Hardware-Tausch"}]
[{"task_id":"1","list_catalog_id":"11","list_catalog_task":"Akku Aufschrauben","list_catalog_desc":"Akkufach aufschrauben. Dafuer 13 Schrauben entfernen blabla","task_date":null,"target_snr":null}]
我试过一些东西,但似乎什么都不管用。我不明白为什么它只在一个部件上工作,而不在这个部件上

以下是我的NOTORM结构和我使用的表结构:

$structure = new NotORM_Structure_Discovery($pdo, $cache = null, $foreign = '%s_id');
工作流程表:

-- -----------------------------------------------------
-- Table `itec_app_workflow`.`workflow`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `itec_app_workflow`.`workflow` (
  `workflow_id` INT NOT NULL AUTO_INCREMENT,
  `workflow_name` VARCHAR(100) NULL,
  `workflow_desc` VARCHAR(150) NULL,
  `workflow_adv_desc` VARCHAR(150) NULL,
  `product_id` INT NOT NULL,
  `list_category_id` INT NOT NULL,
  PRIMARY KEY (`workflow_id`, `product_id`, `checklist_category_id`),
  INDEX `fk_workflow_produkt1_idx` (`product_id` ASC),
  INDEX `fk_workflow_checklist1_idx` (`list_category_id` ASC),
  CONSTRAINT `fk_workflow_produkt1`
    FOREIGN KEY (`product_id`)
    REFERENCES `itec_app_workflow`.`product` (`product_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_workflow_checklist1`
    FOREIGN KEY (`list_category_id`)
    REFERENCES `itec_app_workflow`.`list_category` (`list_category_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;
产品表:

-- -----------------------------------------------------
-- Table `itec_app_workflow`.`product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `itec_app_workflow`.`product` (
  `product_id` INT NOT NULL AUTO_INCREMENT,
  `product_name` VARCHAR(100) NULL,
  `product_type` VARCHAR(45) NULL,
  `manu_id` INT NOT NULL,
  PRIMARY KEY (`product_id`, `manu_id`),
  INDEX `fk_produkt_hersteller1_idx` (`manu_id` ASC),
  CONSTRAINT `fk_produkt_hersteller1`
    FOREIGN KEY (`manu_id`)
    REFERENCES `itec_app_workflow`.`manufacturer` (`manu_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;
任务列表解决方案、列表目录和任务:

-- -----------------------------------------------------
-- Table `itec_app_workflow`.`task`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `itec_app_workflow`.`task` (
  `task_id` INT NOT NULL AUTO_INCREMENT,
  `task_date` DATE NULL,
  `task_deadline` DATETIME(6) NULL,
  `target_snr` VARCHAR(45) NULL,
  `client_id` INT NOT NULL,
  `tech_id` INT NOT NULL,
  `workflow_id` INT NOT NULL,
  `task_type_id` INT NOT NULL,
  PRIMARY KEY (`task_id`, `client_id`, `tech_id`, `workflow_id`, `task_type_id`),
  INDEX `fk_auftrag_kunden1_idx` (`client_id` ASC),
  INDEX `fk_auftrag_techniker1_idx` (`tech_id` ASC),
  INDEX `fk_auftrag_workflow1_idx` (`workflow_id` ASC),
  INDEX `fk_auftrag_auftrags_typ1_idx` (`task_type_id` ASC),
  CONSTRAINT `fk_auftrag_kunden1`
    FOREIGN KEY (`client_id`)
    REFERENCES `itec_app_workflow`.`client` (`client_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_auftrag_techniker1`
    FOREIGN KEY (`tech_id`)
    REFERENCES `itec_app_workflow`.`tech` (`tech_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_auftrag_workflow1`
    FOREIGN KEY (`workflow_id`)
    REFERENCES `itec_app_workflow`.`workflow` (`workflow_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_auftrag_auftrags_typ1`
    FOREIGN KEY (`task_type_id`)
    REFERENCES `itec_app_workflow`.`task_type` (`type_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `itec_app_workflow`.`list_catalog`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `itec_app_workflow`.`list_catalog` (
  `list_catalog_id` INT NOT NULL AUTO_INCREMENT,
  `list_catalog_task` VARCHAR(150) NULL,
  `list_catalog_desc` VARCHAR(150) NULL,
  PRIMARY KEY (`list_catalog_id`))
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `itec_app_workflow`.`task_list_solution`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `itec_app_workflow`.`task_list_solution` (
  `task_list_solution_id` INT NOT NULL AUTO_INCREMENT,
  `task_list_solution_answer` TINYINT(1) NULL,
  `list_catalog_id` INT NOT NULL,
  `task_id` INT NOT NULL,
  PRIMARY KEY (`task_list_solution_id`, `list_catalog_id`, `task_id`),
  INDEX `fk_auftr_checklist_solution_check_katalog1_idx` (`list_catalog_id` ASC),
  INDEX `fk_auftr_checklist_solution_auftrag1_idx` (`task_id` ASC),
  CONSTRAINT `fk_auftr_checklist_solution_check_katalog1`
    FOREIGN KEY (`list_catalog_id`)
    REFERENCES `itec_app_workflow`.`list_catalog` (`list_catalog_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_auftr_checklist_solution_auftrag1`
    FOREIGN KEY (`task_id`)
    REFERENCES `itec_app_workflow`.`task` (`task_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;
我真的希望你们能帮我

顺便说一句:加入PHPMYADMIN工作正常(没有空值),但我不明白为什么