本文整理匯總了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();
}