本文整理汇总了PHP中Dog类的典型用法代码示例。如果您正苦于以下问题:PHP Dog类的具体用法?PHP Dog怎么用?PHP Dog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
public static function start()
{
$target = isset($_GET['target']) ? $_GET['target'] : 'showForm';
switch ($target) {
case 'register':
require_once dirname(__FILE__) . '/ParticipationView.php';
if (isset($_GET['idExhibition']) && $_GET['idExhibition'] > 0) {
require_once dirname(__FILE__) . '/Dog.php';
$dog = new Dog();
$dog->setBreed('retriiver')->setGender('m')->setBirthDate('2000-12-21');
require_once dirname(__FILE__) . '/Exhibition.php';
$exhibition = new Exhibition();
$exhibition->setId($_GET['idExhibition']);
$exhibition->setCompleteExhibition();
$exhibition->insertDog($dog);
echo ParticipationView::buildMessage(array('dog' => $dog, 'exhibition' => $exhibition));
} else {
echo ParticipationView::buildErrorMessage();
}
break;
case 'showForm':
default:
require_once dirname(__FILE__) . '/Exhibition.php';
$exhibitions = Exhibition::getListOfTypeExhibitions();
require_once dirname(__FILE__) . '/ParticipationView.php';
echo ParticipationView::buildRegistrationForm(array('exhibitions' => $exhibitions));
break;
}
}
示例2: testCallback_ManyConditions_CalledBack
/**
* @throws \ValidationException
* @throws null
*/
public function testCallback_ManyConditions_CalledBack()
{
$dog = new Dog();
$dog->Name = 'Johnny';
$owner1 = new Human();
$owner1->Name = 'Bob';
$owner2 = new Human();
$owner2->Name = 'Wot';
$cat = new Cat();
$cat->Name = 'Agnis';
$afterExists = new \OnAfterExists(function () use($dog) {
$dog->write();
});
$afterExists->addCondition($owner1, function ($owner) use($dog) {
$dog->Name .= ' ' . $owner->Name;
$dog->OwnerID = $owner->ID;
});
$afterExists->addCondition($owner2, function ($owner) use($dog) {
$dog->Name .= ' ' . $owner->Name;
$dog->OwnerID = $owner->ID;
});
$afterExists->addCondition($cat, function ($cat) use($dog) {
$dog->Name .= ' ' . $cat->Name;
});
$owner1->write();
$this->assertFalse($dog->exists());
$owner2->write();
$this->assertFalse($dog->exists());
$cat->write();
$this->assertTrue($dog->exists());
$this->assertEquals($owner2->ID, $dog->OwnerID);
$this->assertEquals('Johnny Bob Wot Agnis', $dog->Name);
}
示例3: testShouldChooseOnlyTheFavorite
public function testShouldChooseOnlyTheFavorite()
{
$priority = array('Balsamao', 'Fernando', 'Evaldo', 'Tagliati');
$dog = new Dog($priority);
$availablePeople = array('Fernando', 'Balsamao');
$result = $dog->chooseFavoritePerson($availablePeople);
$expect = "Not Found";
$this->assertEquals($expect, $result);
}
示例4: testDog
public function testDog()
{
$dog = new Dog("Benji");
$this->assertEquals("Benji", $dog->getName());
$this->assertEquals("Benji the Dog", (string) $dog);
$dog->setName("Rover");
$this->assertEquals("Rover", $dog->getName());
$this->assertEquals("Rover the Dog", (string) $dog);
}
示例5: addNewPhotos
public function addNewPhotos(Dog $dog)
{
$dogID = $dog->getID();
$stmt = $this->db->prepare("select " . self::$headShot . ",\n " . self::$standLeft . ",\n " . self::$standRight . ",\n " . self::$eventPlace . ",\n " . self::$eventDate . ",\n " . self::$eventDescr . ",\n " . self::$photographer . ",\n " . self::$isPuppy . "\n from dog\n INNER JOIN images ON dog.dogID = images.dogID\n INNER JOIN event ON images.eventID = event.eventID\n INNER JOIN photographer ON images.photographerID = photographer.photographerID\n where dog.dogID ='{$dogID}'");
if ($stmt === FALSE) {
throw new \Exception($this->db->error);
}
$stmt->execute();
$stmt->bind_result($headshot, $standLeft, $standRight, $eventPlace, $eventDate, $eventDescr, $photographer, $isPuppy);
while ($stmt->fetch()) {
$photo = new Photo($headshot, $standLeft, $standRight, $eventDate, $this->encodeToIso($eventPlace), $this->encodeToIso($eventDescr), $this->encodeToIso($photographer), $isPuppy);
$dog->addPhoto($photo);
}
}
示例6: reply
public function reply($message)
{
Dog::reply($message);
return true;
// if (true === $this->player->isOptionEnabled(SR_Player::WWW_OUT))
// {
// $this->player->message($message);
// }
// else
// {
// Dog::reply($message);
// if (NULL === ($user = $this->player->getUser()))
// {
// echo "PLAYER HAS NO USER IN SHADOWRAP.\n";
// }
// elseif (false === ($server = $user->getServer()))
// {
// echo "USER HAS NO SERVER IN SHADOWRAP.\n";
// }
// else
// {
// # BAH
// }
// }
// return true;
}
示例7: providerRequestPing
public function providerRequestPing()
{
$walker_id = Session::get('walker_id');
$time = date("Y-m-d H:i:s");
$query = "SELECT id,owner_id,TIMESTAMPDIFF(SECOND,request_start_time, '{$time}') as diff from request where is_cancelled = 0 and status = 0 and current_walker={$walker_id} and TIMESTAMPDIFF(SECOND,request_start_time, '{$time}') <= 600 limit 1";
$requests = DB::select(DB::raw($query));
$request_data = array();
foreach ($requests as $request) {
$request_data['success'] = "true";
$request_data['request_id'] = $request->id;
$request_data['time_left_to_respond'] = 600 - $request->diff;
$owner = Owner::find($request->owner_id);
$request_data['owner'] = array();
$request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
$request_data['owner']['picture'] = $owner->picture;
$request_data['owner']['phone'] = $owner->phone;
$request_data['owner']['address'] = $owner->address;
$request_data['owner']['latitude'] = $owner->latitude;
$request_data['owner']['longitude'] = $owner->longitude;
$request_data['owner']['rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->avg('rating') ?: 0;
$request_data['owner']['num_rating'] = DB::table('review_dog')->where('owner_id', '=', $owner->id)->count();
$request_data['dog'] = array();
if ($dog = Dog::find($owner->dog_id)) {
$request_data['dog']['name'] = $dog->name;
$request_data['dog']['age'] = $dog->age;
$request_data['dog']['breed'] = $dog->breed;
$request_data['dog']['likes'] = $dog->likes;
$request_data['dog']['picture'] = $dog->image_url;
}
}
$response_code = 200;
$response = Response::json($request_data, $response_code);
return $response;
}
示例8: testBranchDeleteIDs_DeleteManyIDs_ObjectsDeleted
/**
* @throws \ValidationException
* @throws null
*/
public function testBranchDeleteIDs_DeleteManyIDs_ObjectsDeleted()
{
$className = '';
$ids = array();
for ($i = 0; $i < 100; $i++) {
$dog = new Dog();
$dog->Name = 'Pup ' . $i;
$dog->Color = 'Fifty Shade No. ' . $i;
$dog->write();
$className = $dog->ClassName;
$ids[] = $dog->ID;
}
$batch = new \Batch();
$batch->deleteIDs($className, $ids);
$this->assertEquals(0, Dog::get()->Count());
}
示例9: testCallback_SetOnAfterExistsCallback_CallbackCalled
/**
* @throws \ValidationException
* @throws null
*/
public function testCallback_SetOnAfterExistsCallback_CallbackCalled()
{
$dog1 = new Dog();
$dog1->Name = 'Jim bob';
$dog2 = new Dog();
$dog2->Name = 'Super Dog';
$owner = new Human();
$owner->Name = 'Hilly Stewart';
$owner->write();
$owner->onAfterExistsCallback(function ($owner) use($dog1) {
$dog1->OwnerID = $owner->ID;
$dog1->write();
});
$owner->write();
$owner->onAfterExistsCallback(function ($owner) use($dog2) {
$dog2->OwnerID = $owner->ID;
$dog2->write();
});
$this->assertTrue($owner->exists());
$this->assertTrue($dog1->exists());
$this->assertTrue($dog2->exists());
$this->assertEquals(1, Human::get()->Count());
$this->assertEquals(2, Dog::get()->Count());
$this->assertEquals($owner->ID, $dog1->OwnerID);
$this->assertEquals($owner->ID, $dog2->OwnerID);
}
示例10: getAutoTargetISO
private static function getAutoTargetISO()
{
if (false !== ($channel = Dog::getChannel())) {
return $channel->getLangISO();
} else {
return Dog::getUser()->getLangISO();
}
}
示例11: connect
public static function connect(Dog_Server $server)
{
if (false === ($nick = self::getNickData($server))) {
return Dog_Log::warn(sprintf('No nicks for %s.', $server->displayName()));
}
$server->addUser(Dog::getOrCreateUserByName($nick->getName()));
$conn = $server->getConnection();
return self::sendUser($conn, $server, $nick) && self::sendNick($conn, $server, $nick);
}
示例12: claim
public function claim()
{
foreach (Dog::getServers() as $server) {
$server instanceof Dog_Server;
if ($this->isEnabled($server, false) && $server->isConnected()) {
$this->claimServer($server);
}
}
}
示例13: dog_plugin_alert_func4
function dog_plugin_alert_func4(array $args)
{
global $DOG_PLUG_ALERT_TIMERS;
$scope = $args[0];
$scope instanceof Dog_Scope;
Dog::setScope($scope);
Dog::reply($args[1]);
$DOG_PLUG_ALERT_TIMERS[$scope->getUser()->getID()]--;
}
示例14: announceVideo
private function announceVideo(array $data)
{
// Pick ISO for channel?
if (false !== ($chan = Dog::getChannel())) {
$iso = $chan->getLangISO();
} else {
$iso = Dog::getUser()->getLangISO();
}
$vars = array($data['title'], GWF_TimeConvert::humanDurationISO($iso, $data['duration']), sprintf('%.02f', $data['rating']), number_format($data['views']), number_format($data['num_raters']));
Dog::reply($this->langISO($iso, 'video', $vars));
}
示例15: testWrite_WriteObjects_ObjectsWritten
/**
*
*/
public function testWrite_WriteObjects_ObjectsWritten()
{
$batchSizes = array(10, 30, 100, 300);
foreach ($batchSizes as $size) {
$owners = array();
$dogs = array();
$cats = array();
$writer = new \BatchedWriter($size);
for ($i = 0; $i < 100; $i++) {
$owner = new Human();
$owner->Name = 'Human ' . $i;
$dog = new Dog();
$dog->Name = 'Dog ' . $i;
$cat = new Cat();
$cat->Name = 'Cat ' . $i;
$owner->onAfterExistsCallback(function ($owner) use($dog, $writer) {
$dog->OwnerID = $owner->ID;
$writer->write($dog);
});
$dog->onAfterExistsCallback(function ($dog) use($cat, $writer) {
$cat->EnemyID = $dog->ID;
$writer->write($cat);
});
$owners[] = $owner;
$dogs[] = $dog;
$cats[] = $cat;
}
// writes dogs first time
$writer->write($dogs);
// dogs written again from owner callback
$writer->write($owners);
$writer->finish();
$owners = Human::get();
$dogs = Dog::get();
$cats = Cat::get();
$this->assertEquals(100, $owners->Count());
$this->assertEquals(100, $dogs->Count());
$this->assertEquals(100, $cats->Count());
for ($i = 0; $i < 100; $i++) {
$owner = $owners[$i];
$dog = $dogs[$i];
$cat = $cats[$i];
$this->assertEquals($owner->ID, $dog->OwnerID);
$this->assertEquals($dog->ID, $cat->EnemyID);
}
$writer->delete($owners);
$writer->delete($dogs);
$writer->delete($cats);
$writer->finish();
$this->assertEquals(0, Human::get()->Count());
$this->assertEquals(0, Dog::get()->Count());
$this->assertEquals(0, Cat::get()->Count());
}
}