コード例 #1
0
ファイル: JobController.php プロジェクト: kbcmdba/pjs2
    public function getSome($whereClause = '1 = 1')
    {
        $sql = <<<SQL
SELECT id
     , primaryContactId
     , companyId
     , applicationStatusId
     , lastStatusChange
     , urgency
     , created
     , updated
     , nextActionDue
     , nextAction
     , positionTitle
     , location
     , url
  FROM job
 WHERE {$whereClause}
 ORDER
    BY nextActionDue DESC
SQL;
        $stmt = $this->_dbh->prepare($sql);
        if (!$stmt) {
            throw new ControllerException('Failed to prepare SELECT statement. (' . $this->_dbh->error . ') ' . $sql);
        }
        if (!$stmt->execute()) {
            throw new ControllerException('Failed to execute SELECT statement. (' . $this->_dbh->error . ')');
        }
        $stmt->bind_result($id, $primaryContactId, $companyId, $applicationStatusId, $lastStatusChange, $urgency, $created, $updated, $nextActionDue, $nextAction, $positionTitle, $location, $url);
        $models = array();
        while ($stmt->fetch()) {
            $model = new JobModel();
            $model->setId($id);
            $model->setPrimaryContactId($primaryContactId);
            $model->setCompanyId($companyId);
            $model->setApplicationStatusId($applicationStatusId);
            $model->setLastStatusChange($lastStatusChange);
            $model->setUrgency($urgency);
            $model->setCreated($created);
            $model->setUpdated($updated);
            $model->setNextActionDue($nextActionDue);
            $model->setNextAction($nextAction);
            $model->setPositionTitle($positionTitle);
            $model->setLocation($location);
            $model->setUrl($url);
            $models[] = $model;
        }
        return $models;
    }