本文整理汇总了PHP中Brand类的典型用法代码示例。如果您正苦于以下问题:PHP Brand类的具体用法?PHP Brand怎么用?PHP Brand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Brand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Modelo();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Modelo'])) {
$model->attributes = $_POST['Modelo'];
if ($model->save()) {
if (!empty($_POST['yt1'])) {
Yii::app()->user->setFlash('modelo-created', "¡El modelo <b><i>"{$model->name}"</i></b> fue creado exitosamente!");
//$this->redirect(array('create'));
$modelSaved = $model;
$model = new Modelo();
$model->equipment_type_id = $modelSaved->equipment_type_id;
$model->brand_id = $modelSaved->brand_id;
} else {
$this->redirect(array('view', 'id' => $model->id));
}
}
}
if (EquipmentType::model()->count('active = 1') == 0 && Brand::model()->count('active = 1') == 0) {
throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . ' y ' . CHtml::link('crear una Marca', array('brand/create')) . '.');
} else {
if (EquipmentType::model()->count('active = 1') == 0) {
throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . '.');
} else {
if (Brand::model()->count('active = 1') == 0) {
throw new CHttpException('', 'Primero debe ' . CHtml::link('crear una Marca', array('brand/create')) . '.');
} else {
$this->render('create', array('model' => $model));
}
}
}
}
示例2: testImages
public function testImages()
{
$brand = new \Brand(array('title' => 'test'));
$brand->save();
$brand->attachFileFromPath('avatar', __DIR__ . '/assets/flower.jpg');
$this->assertEquals('04/4/avatar/small/' . $brand->avatar['full_name'], $brand->avatar['small']['link'], 'Small avatar works');
}
示例3: testForTest
public function testForTest()
{
TranslateAbility::setLanguageId(1);
$brand = new \Brand(array('title' => 'Apple'));
$this->assertEquals('Apple', $brand->title, 'Accessor after creating');
$brand->save();
$this->assertEquals('Apple', $brand->title, 'Accessor after saving');
$brand = \Brand::loadOne(1);
$this->assertEquals('Apple', $brand->title, 'Accessor after loading');
$this->assertEquals(array('id_language' => 1, 'id_object' => 1, 'title' => 'Apple'), QC::create('brands_translate')->executeOne(), 'Data stored in DB after saving');
TranslateAbility::setLanguageId(2);
$brand->title = 'Яблоко';
$brand->save();
$this->assertEquals('Яблоко', $brand->title, 'Accessor after loading');
$this->assertEquals(array('id_language' => 2, 'id_object' => 1, 'title' => 'Яблоко'), QC::create('brands_translate')->where('id_language = :d', 2)->executeOne(), 'Data stored in DB after saving');
$brand->loadTranslation(1);
$this->assertEquals('Apple', $brand->title, 'loadTranslation works');
$this->assertEquals(array('id' => 1, 'id_object' => 1, 'id_language' => 2, 'title' => 'Яблоко'), $brand->getTranslationForLanguage(2), 'getTranslationForLanguage');
TranslateAbility::setLanguageId(1);
$brand2 = new \Brand();
$brand2->title = 'Samsung';
$brand2->save();
$brand2->loadTranslation(2);
$this->assertEmpty($brand2->title, 'Empty data for not translated item');
$brands = \Brand::loadList();
$this->assertEquals(array('Apple', 'Samsung'), $brands->getFieldArray('title'), 'Loaded two translated items');
$brands->loadTranslation(2);
$this->assertEquals(array('Яблоко', null), $brands->getFieldArray('title'), 'Loaded two not fully translated items');
$this->assertEquals(array(1 => array('id' => 1, 'id_object' => 1, 'id_language' => 1, 'title' => 'Apple'), 2 => array('id' => 1, 'id_object' => 1, 'id_language' => 2, 'title' => 'Яблоко')), $brand->getAllTranslations(), 'getAllTranslations()');
}
示例4: run
public function run()
{
DB::table('brands')->truncate();
$brand = new Brand();
$brand->name = "5TheWay";
$brand->save();
$brand = new Brand();
$brand->name = "Nike";
$brand->save();
$brand = new Brand();
$brand->name = "Adidas";
$brand->save();
$brand = new Brand();
$brand->name = "Puma";
$brand->save();
$brand = new Brand();
$brand->name = "Ripcurl";
$brand->save();
$brand = new Brand();
$brand->name = "The Northface";
$brand->save();
$brand = new Brand();
$brand->name = "Overdose";
$brand->save();
$brand = new Brand();
$brand->name = "Kenstyle";
$brand->save();
$brand = new Brand();
$brand->name = "Real Tree";
$brand->save();
$brand = new Brand();
$brand->name = "Game Guard";
$brand->save();
}
示例5: postSave
public function postSave()
{
$brand = new Brand();
$brand->client_id = Input::get('client_id');
$brand->brand_name = Input::get('brand_name');
$brand->category_id = Input::get('category_id');
$brand->save();
return Response::json($brand);
}
示例6: insert
public function insert(Category $category, Subcategory $subcategory, Brand $brand, Item $item)
{
// $sql = "INSERT INTO item values (null, 'aalluu', 'asdfasd',true,true, '2015-10-10','asdfasf', 'asdfasd', 1, 1 ,1, 1)";
$sql = "INSERT INTO item values (null, '" . $item->getTitle() . "','" . $item->getDetail() . "',true,false, '" . $item->getDate() . "', '" . $item->getLocation() . "','asfasf'," . $category->getId() . "," . $subcategory->getId() . ", 1 ," . $brand->getId() . ")";
echo $sql;
if ($this->conn->query($sql) === TRUE) {
echo "Insert operation successful";
} else {
echo "Error inserting: ";
}
}
示例7: executeAddBrand
public function executeAddBrand(sfWebRequest $request)
{
try {
$q = new Brand();
$q->setBrandName($request->getParameter('brand_name'));
$q->save();
$this->res = "Brand Added!";
} catch (Exception $exc) {
$this->res = $exc->getMessage();
}
}
示例8: test_delete
function test_delete()
{
$name = "Nike";
$test_brand = new Brand($name, $id);
$test_brand->save();
$name2 = "Adidas";
$test_brand2 = new Brand($name2, $id);
$test_brand2->save();
$test_brand->delete();
$this->assertEquals([$test_brand2], Brand::getAll());
}
示例9: testAddBrand
function testAddBrand()
{
$store_name = "Beacons Closet";
$new_store = new Store($store_name);
$new_store->save();
$brand_name = "dr.martens";
$new_brand = new Brand($brand_name);
$new_brand->save();
$new_store->addBrand($new_brand);
$result = $new_store->getBrands();
$this->assertEquals($new_brand, $result[0]);
}
示例10: testDelete
function testDelete()
{
$name = "Zelds";
$test_store = new Store($name);
$test_store->save();
$name = "Granite";
$test_brand = new Brand($name);
$test_brand->save();
$test_brand->addStore($test_brand);
$test_brand->delete();
$this->assertEquals([], $test_brand->getStores());
}
示例11: testBasic
public function testBasic()
{
$brand = new \Brand(array('title' => 'Apple'));
$brand->save();
$this->assertEquals('apple', $brand->getSlug(), 'slug ability for Apple');
$brand->setTitle('Саша')->save();
$this->assertEquals('sasha', $brand->getSlug(), 'slug ability for Sasha');
$brand->setTitle('')->save();
$this->assertEquals('n-a', $brand->getSlug(), 'slug ability for empty');
$brand->setTitle('12 -_ s')->save();
$this->assertEquals('12-s', $brand->getSlug(), 'slug ability for bad string');
}
示例12: __construct
function __construct()
{
$this->api_config_arr = (include_once '/protected/config/Api_config.php');
foreach ($this->api_config_arr as $config_key => $config_value) {
unset($this->api_config_arr[$config_key]['Tmall']['brandkey']);
}
$brand_docking_ret = Brand::getbranddocking('*', array('status' => '=1'));
if ($brand_docking_ret['status'] == 1) {
foreach ($brand_docking_ret['data'] as $value) {
$is_bool = false;
foreach ($this->api_config_arr as $config_key => $config_value) {
if ($value['brandid'] == $config_value['brandid']) {
if (!isset($this->api_config_arr[$config_key]['Tmall'])) {
$this->api_config_arr[$config_key]['Tmall'] = array();
}
$this->api_config_arr[$config_key]['Tmall']['brandkey'] = $value['tamllid'];
$is_bool = true;
}
}
if (!$is_bool) {
$this->api_config_arr[] = array('brandid' => $value['brandid'], 'Tmall' => array('brandkey' => $value['tamllid']));
}
}
}
}
示例13: news
/**
* 返回图文模板 - 多条图文,故采用方法,直接返回格式化后的字符串
* @param String $fromUserName 发送方
* @param String $toUserName 接收方
* @param Array $arr 一维度数组 或 二维数组,代表一个图文消息里多个条目
* @param Integer $brandId 品牌主键
* 注意:
* 数组$arr可以是关联数组,且存在键 title, description, pic_url, url
* 也可以是索引数组,则0-3对应上述相应的值,不可错乱
*
* picUrl限制图片链接的域名需要与开发者填写的基本资料中的Url一致
*/
public static function news($fromUserName, $toUserName, $arr, $brandId)
{
if (ArrayUtil::depth($arr) == 1) {
// 一维数组,图文一条条目
if (isset($v['title'])) {
return sprintf(PushTemplates::NEWS, $fromUserName, $toUserName, time(), $arr['title'], $arr['description'], Brand::fullPicUrl($arr['pic_url'], $brandId), URLOauth::redirect($brandId, $arr['url']));
} else {
return sprintf(PushTemplates::NEWS, $fromUserName, $toUserName, time(), $arr[0], $arr[1], Brand::fullPicUrl($arr[2], $brandId), URLOauth::redirect($brandId, $arr[3]));
}
} else {
// 二维数组,图文多条条目
$item = "<item>\n\t\t\t\t <Title><![CDATA[%s]]></Title> \n\t\t\t\t <Description><![CDATA[%s]]></Description>\n\t\t\t\t <PicUrl><![CDATA[%s]]></PicUrl>\n\t\t\t\t <Url><![CDATA[%s]]></Url>\n\t\t\t\t </item>";
$itemStr = '';
foreach ($arr as $v) {
if (isset($v['title'])) {
$itemStr .= sprintf($item, $v['title'], $v['description'], Brand::fullPicUrl($v['pic_url'], $brandId), URLOauth::redirect($brandId, $v['url']));
} else {
$itemStr .= sprintf($item, $v[0], $v[1], Brand::fullPicUrl($v[2], $brandId), URLOauth::redirect($brandId, $v[3]));
}
}
// 注意,不能在此处 $tbl . $itemStr ."</Articles>...",然后再sprintf因此URLOauth中的网址包含了转义字符%s等,造成sprintf参数太少的错误
$tbl = "<xml>\n\t\t\t\t\t <ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t <FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t <CreateTime>%s</CreateTime>\n\t\t\t\t\t <MsgType><![CDATA[news]]></MsgType>\n\t\t\t\t\t <ArticleCount>" . count($arr) . "</ArticleCount>\n\t\t\t\t\t <Articles>\n\t\t\t\t\t\t ";
$frontPortion = sprintf($tbl, $fromUserName, $toUserName, time());
return $frontPortion . $itemStr . "\n\t\t\t\t\t </Articles>\n\t\t\t\t\t <FuncFlag>1</FuncFlag>\n\t\t\t\t\t </xml>";
}
}
示例14: actionIndex
public function actionIndex()
{
$product_id = intval($_REQUEST['id']);
$pInfo = Product::model()->getProductInfoById($product_id);
if (empty($pInfo)) {
$this->redirect('/?from=no_goods');
//跳转到首页
}
$brandInfo = '';
if ($pInfo['brand_id']) {
$brandInfo = Brand::model()->findByPk($pInfo['brand_id']);
}
$stock = Product::model()->getProductStock($product_id, $pInfo['is_multiple']);
$attrList = ProductAttributes::model()->getProductAttrNameList();
$extendAttrList = ProductExtend::model()->getProductExtendAttrs($product_id);
$is_like = Like::model()->getLikeStatus($this->user_id, $product_id);
$cake = Category::model()->getCakeLine($pInfo['cat_id']);
//获取商品的面包屑
$viewData = array();
$viewData['pInfo'] = $pInfo;
$viewData['brandInfo'] = $brandInfo;
$viewData['is_like'] = $is_like;
$viewData['cake'] = $cake;
$viewData['stock'] = $stock;
$viewData['attrList'] = $attrList;
$viewData['extendAttrList'] = $extendAttrList;
$this->render('item/index', $viewData);
}
示例15: scopeBrand
public function scopeBrand($query, $id)
{
$brands = Brand::lists('name', 'id');
if ($id != "" && isset($brands[$id])) {
$query->where('brand_id', $id);
}
}