本文整理汇总了PHP中Car::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::findOne方法的具体用法?PHP Car::findOne怎么用?PHP Car::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::findOne方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Brand
$brand = new Brand();
$brand->nameBrand = "Peugeot";
$brand->save();
// creating a car
// and affecting $brand to them
$car = new Car();
$car->nameCar = "205 GTi";
$car->setBrand($brand);
$car->save();
// setting car's brand
$car->setBrand($brand);
// other way to setting car's brand
$car->idBrand = $brand->idBrand;
$car->save();
// we look for our car
$car = Car::findOne(array('nameCar' => '205 GTi'));
// get brand of the car
$car->getBrand();
// you can access brand name directy because it has been added to relation autoget fields
$car->nameBrand;
// creating some tags
$tag = new Tag();
$tag->libTag = 'tag 1';
$tag->save();
$tag2 = new Tag();
$tag2->libTag = 'tag 2';
$tag2->save();
$tag3 = new Tag();
$tag3->libTag = 'tag 3';
$tag3->save();
// setting car's tags
示例2: testOneToOneRelation
/**
* @engine isolate
* @dataProvider createAndSaveRawModelWithOneToOneRelation
*/
public function testOneToOneRelation($testBrand, $car, $dbRes)
{
$this->string($car->getBrand()->nameBrand)->isEqualTo($testBrand->nameBrand)->string(\Car::findOne(array('idCar' => $car->idCar))->nameBrand)->isEqualTo($testBrand->nameBrand);
}