Beispiel #1
0
    /**
     * @param string $whereClause
     * @see ControllerBase::getSome()
     */
    public function getSome($whereClause = '1 = 1')
    {
        $sql = <<<SQL
SELECT id
     , keywordValue
     , sortKey
     , created
     , updated
  FROM keyword
 WHERE {$whereClause}
 ORDER
    BY sortKey
SQL;
        $stmt = $this->_dbh->prepare($sql);
        if (!$stmt) {
            throw new ControllerException('Failed to prepare SELECT statement. (' . $this->_dbh->error . ')');
        }
        if (!$stmt->execute()) {
            throw new ControllerException('Failed to execute SELECT statement. (' . $this->_dbh->error . ')');
        }
        $stmt->bind_result($id, $keywordValue, $sortKey, $created, $updated);
        $models = array();
        while ($stmt->fetch()) {
            $model = new KeywordModel();
            $model->setId($id);
            $model->setKeywordValue($keywordValue);
            $model->setSortKey($sortKey);
            $model->setCreated($created);
            $model->setUpdated($updated);
            $models[] = $model;
        }
        return $models;
    }