本文整理汇总了PHP中Brand::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Brand::getId方法的具体用法?PHP Brand::getId怎么用?PHP Brand::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brand
的用法示例。
在下文中一共展示了Brand::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Brand
function test_getId()
{
$name = "Nike";
$id = 1;
$test_brand = new Brand($name, $id);
$result = $test_brand->getId();
$this->assertEquals(true, is_numeric($result));
}
示例2: getId
/**
* Get the Phone Model id from database
* @param string|int $brand
* @param string $phoneModel
* @return int
*/
public static function getId($brand, $phoneModel)
{
$brandId = is_numeric($brand) ? (int) $brand : \Brand::getId($brand);
$model = static::fetchOne(array('brand_id' => $brandId, 'name' => $phoneModel));
if ($model === false) {
$model = static::create(array('brand_id' => $brandId, 'name' => $phoneModel));
}
return $model->id;
}
示例3: getId
/**
* Get the product ID from database
* @param string|int $brand
* @param string $productName
* @return int
*/
public static function getId($brand, $productName)
{
$brandId = is_numeric($brand) ? (int) $brand : \Brand::getId($brand);
$product = static::fetchOne(array('brand_id' => $brandId, 'name' => $productName));
if ($product === false) {
$product = static::create(array('brand_id' => $brandId, 'name' => $productName));
}
return $product->id;
}
示例4: getBrandId
/**
* Get the brand ID
* @param string $brand
* @return int
*/
private function getBrandId($brand)
{
if ($brand === null || trim($brand) == '') {
return null;
}
if (!isset($this->brandIds[$brand])) {
$this->brandIds[$brand] = Brand::getId($brand);
}
return $this->brandIds[$brand];
}
示例5: 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: ";
}
}
示例6: testFind
function testFind()
{
$brand_name = "Air Jordan";
$test_brand = new Brand($brand_name);
$test_brand->save();
$brand_name2 = "Nike";
$test_brand2 = new Brand($brand_name2);
$test_brand2->save();
$result = Brand::find($test_brand->getId());
$this->assertEquals($test_brand, $result);
}
示例7: testFind
function testFind()
{
$name = "Clides";
$test_brand = new Brand($name);
$test_brand->save();
$name2 = "Marthas";
$test_brand2 = new Brand($name2);
$test_brand2->save();
$result = Brand::find($test_brand->getId());
$this->assertEquals($test_brand, $result);
}
示例8: testGetId
function testGetId()
{
//Arrange
$name = "addidas";
$id = 1;
$test_brand = new Brand($name, $id);
//Act
$result = $test_brand->getId();
//Assert
$this->assertEquals($id, $result);
}
示例9: Brand
function test_find()
{
//Arrange
$brand_name = "Nike";
$test_brand = new Brand($id, $brand_name);
$test_brand->save();
$brand_name2 = "Adidas";
$test_brand2 = new Brand($id, $brand_name2);
$test_brand2->save();
//Act
$result = Brand::find($test_brand->getId());
//Assert
$this->assertEquals($test_brand, $result);
}
示例10: testFind
function testFind()
{
//Arrange
$brand_name = "Nike";
$test_brand = new Brand($brand_name, $id);
$test_brand->save();
$brand_name2 = "Reebok";
$test_brand2 = new Brand($brand_name2, $id2);
$test_brand2->save();
//Act
$result = Brand::find($test_brand2->getId());
//assert
$this->assertEquals($test_brand2, $result);
}
示例11: testFind
function testFind()
{
//Arrange
$brand_name = "Feiyue";
$test_brand = new Brand($brand_name, $id = null);
$test_brand->save();
$brand_name2 = "Kailai";
$test_brand2 = new Brand($brand_name2, $id = null);
$test_brand2->save();
//Act
$result = Brand::find($test_brand->getId());
//Assert
$this->assertEquals($test_brand, $result);
}
示例12: delete
public function delete(Brand $brand)
{
$query = "DELETE FROM brand WHERE id = " . $brand->getId();
$data = $this->db->exec($query);
if ($data) {
return true;
} else {
throw new Exception('Delete error');
}
}
示例13: Brand
function test_brand_find()
{
//Arrange
$brand_name = "Nike";
$id1 = 1;
$test_brand = new Brand($brand_name, $id1);
$test_brand->save();
$brand_name2 = "Converse";
$id2 = 2;
$test_brand2 = new Brand($brand_name2, $id2);
$test_brand2->save();
//Act
$result = Brand::find($test_brand->getId());
//Assert
$this->assertEquals($test_brand, $result);
}
示例14: Brand
function test_find()
{
//Arrange
$brand_name = "La Sportiva";
$test_brand = new Brand($brand_name);
$test_brand->save();
$brand_name2 = "Evolv";
$test_brand2 = new Brand($brand_name2);
$test_brand2->save();
//Act
$result = Brand::find($test_brand->getId());
//Assert
$this->assertEquals($test_brand, $result);
}
示例15: Brand
function test_find()
{
//Arrange
$name = "Nike";
$website = "http://www.nike.com";
$test_brand = new Brand($name, $website);
$test_brand->save();
$name2 = "Adidas";
$website2 = "http://www.adidas.com";
$test_brand2 = new Brand($name2, $website2);
$test_brand2->save();
//Act
$result = Brand::find($test_brand2->getId());
//Assert
$this->assertEquals($test_brand2, $result);
}