本文整理汇总了PHP中product::model方法的典型用法代码示例。如果您正苦于以下问题:PHP product::model方法的具体用法?PHP product::model怎么用?PHP product::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product
的用法示例。
在下文中一共展示了product::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDeleteProduct
public function actionDeleteProduct()
{
$errors = array();
if (!isset($_GET['value'])) {
$errors[] = 'A product ID must be supplied';
} else {
if (!is_numeric($_GET['value'])) {
$errors[] = "Provided product ID must be an integer";
} else {
if ($product = product::model()->getbyPK($_GET['value'])) {
if ($product->delete()) {
$data = array();
} else {
$errors[] = 'Could not delete the product';
}
} else {
$errors[] = 'Could not find product with ID of ' . $_GET['value'];
}
}
}
if (count($errors) > 0) {
$this->renderApi(false, null, $errors);
} else {
$this->renderApi(true, $data);
}
}
示例2: actionDeleteAll
public function actionDeleteAll($id)
{
$arrIdNew = explode(",", $id);
for ($i = 0; $i < count($arrIdNew); $i++) {
// Delete all news of category new
$model = $this->loadModel($arrIdNew[$i]);
if (!empty($model)) {
$criteria = new CDBCriteria();
$criteria->addCondition("product_category_id = {$arrIdNew[$i]}");
$criteria->select = "id";
$arrProduct = Product::model()->findALl($criteria);
foreach ($arrProduct as $product) {
$modelProduct = product::model()->find($product->id);
// delete all images
if (!empty($modelProduct)) {
$criteria = new CDBCriteria();
$criteria->addCondition("product_id = {$modelProduct->id}");
$criteria->select = "id";
$arrImage = ProductImage::model()->findALl($criteria);
foreach ($arrImage as $ProductImage) {
$modelImage = ProductImage::model()->find($ProductImage->id);
$path = "/../upload/images/";
$name = $modelImage->image;
$this->unlink($path, $name);
$modelImage->delete();
}
}
$modelProduct->delete();
}
}
// Delete category new
$model->delete();
}
if (!isset($_GET['ajax'])) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
}
}