本文整理汇总了PHP中Brand::setProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP Brand::setProperties方法的具体用法?PHP Brand::setProperties怎么用?PHP Brand::setProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brand
的用法示例。
在下文中一共展示了Brand::setProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBrands
public function getBrands()
{
$brands = array();
$pdo = DataSource::load();
$data = array();
$statement = 'SELECT brand.*, category.name AS categoryName FROM brand
LEFT JOIN category ON brand.category = category.id
WHERE deleted = 0';
if (!empty($this->categoryId)) {
$statement .= ' AND category = :category';
$data['category'] = $this->categoryId;
}
if ($this->status !== null) {
$statement .= ' AND status = :status';
$data['status'] = $this->status;
}
if (!empty($this->orderBy)) {
$statement .= ' ORDER BY ' . $this->orderBy;
}
if (!empty($this->limit)) {
$statement .= ' LIMIT ' . (int) $this->limit;
}
if (!empty($this->offset)) {
$statement .= ' OFFSET ' . (int) $this->offset;
}
$preparedStatement = $pdo->prepare($statement);
$preparedStatement->execute($data);
$brandsData = $preparedStatement->fetchAll();
foreach ($brandsData as $brandData) {
$brand = new Brand();
$brand->setProperties($brandData);
$brands[] = $brand;
}
return $brands;
}