本文整理汇总了PHP中Products::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Products::fetchAll方法的具体用法?PHP Products::fetchAll怎么用?PHP Products::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products
的用法示例。
在下文中一共展示了Products::fetchAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findProductsCoalesced
/**
* @param int $customerId
*/
public function findProductsCoalesced($customerId)
{
$productsTable = new Products();
$products = $productsTable->fetchAll();
$productsCoalesced = array();
if ($products->count() > 0) {
foreach ($products as $p) {
$cp = $this->find($p->product_id, $customerId)->current();
if ($cp) {
$productsCoalesced[] = array('product_id' => $cp->product_id, 'sku' => $cp->sku ?: $p->sku, 'name' => $cp->name ?: $p->name, 'description' => $cp->description ?: $p->description, 'unit_price' => $cp->unit_price ?: $p->unit_price);
} else {
$productsCoalesced[] = array('product_id' => $p->product_id, 'sku' => $p->sku, 'name' => $p->name, 'description' => $p->description, 'unit_price' => $p->unit_price);
}
}
}
return $productsCoalesced;
}
示例2: indexAction
/**
* View a list of all products
*/
public function indexAction()
{
$productsTable = new Products();
$this->view->products = $productsTable->fetchAll();
}