當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Animal類代碼示例

本文整理匯總了PHP中Animal的典型用法代碼示例。如果您正苦於以下問題:PHP Animal類的具體用法?PHP Animal怎麽用?PHP Animal使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Animal類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_getAnimals

 function test_getAnimals()
 {
     //Arrange
     $type = "dog";
     $id = null;
     $test_animal_type = new AnimalType($type, $id);
     $test_animal_type->save();
     $test_type_id = $test_animal_type->getId();
     $name = 'Sparky';
     $gender = 'Male';
     $breed = 'Pug';
     $admit_date = '2015-08-18';
     $test_animal = new Animal($name, $gender, $breed, $admit_date, $test_type_id);
     $test_animal->save();
     $name2 = 'Senna';
     $gender2 = 'Male';
     $breed2 = 'Domestic Shorthair';
     $admit_date2 = '2015-07-28';
     $test_animal2 = new Animal($name, $gender, $breed, $admit_date, $test_type_id);
     $test_animal2->save();
     //Act
     $result = $test_animal_type->getAnimals();
     //Assert
     $this->assertEquals([$test_animal, $test_animal2], $result);
 }
開發者ID:slmaturen,項目名稱:animal-shelter,代碼行數:25,代碼來源:AnimalTypeTest.php

示例2: perigo

 public function perigo(Animal $p)
 {
     $p->emitirSom();
     $p->dormir();
     //$p->brincar(); Nao vale para todos
     //os animais.
 }
開發者ID:vitorgja,項目名稱:Fatec-rl,代碼行數:7,代碼來源:de_subtipo.php

示例3: getListCountryCityCountryLanguage

 function getListCountryCityCountryLanguage($condicion = null, $parametros = array())
 {
     if ($condicion === null) {
         $condicion = "";
     } else {
         $condicion = "where {$condicion}";
     }
     $sql = " select co.*, ci.*, cl.*\r\n                    from country co\r\n                    left join city ci\r\n                    on co.Code = ci.CountryCode\r\n                    left join countrylanguage cl \r\n                    on co.Code =  cl.CountryCode {$condicion}";
     $this->bd->send($sql, $parametros);
     $r = array();
     $contador = 0;
     while ($fila = $this->bd->getRow()) {
         $country = new Cuidador();
         $country->set($fila);
         $city = new Animal();
         $city->set($fila, 15);
         //el numero es a partir del ultimo campo de country, para que coja los de city
         //$countrylanguage = new CountryLanguage();
         //$countrylanguage->set($fila, 20);
         $r[$contador]["country"] = $country;
         $r[$contador]["city"] = $city;
         //$r[$contador]["countrylanguage"]=$countrylanguage;
         $contador++;
     }
     return $r;
 }
開發者ID:jcfuentes102,項目名稱:ZOO,代碼行數:26,代碼來源:ManageRelations.php

示例4: removeAnimal

 public function removeAnimal(Animal $animal)
 {
     foreach ($this->_group as $key => $current) {
         if ($current->getAnimalName() == $animal->getAnimalName()) {
             unset($this->_group[$key]);
         }
     }
 }
開發者ID:azurecorn,項目名稱:animal_farm,代碼行數:8,代碼來源:AnimalGroup.php

示例5: enqueue

 public function enqueue(Animal $animal)
 {
     $animal->setIndex($this->index++);
     if ($animal instanceof Dog) {
         $this->dogs->add($animal);
     } else {
         if ($animal instanceof Cat) {
             $this->cats->add($animal);
         } else {
             throw new InvalidArgumentException('Unknown animal type: ' + get_class($animal));
         }
     }
 }
開發者ID:SamyGhannad,項目名稱:CtCI-6th-Edition,代碼行數:13,代碼來源:AnimalShelter.php

示例6: register

 public function register($aid, $name, $gender, $age, $type, $u_name, $u_gender, $u_city, $inviter)
 {
     $user = new User();
     $user->name = $u_name;
     $user->gender = $u_gender;
     $user->city = $u_city;
     $user->code = $this->createInviteCode();
     $user->inviter = $inviter;
     $user->gold = 500;
     $reward_items = array(1101 => 3, 1102 => 3, 1103 => 3, 1104 => 3, 1105 => 3, 1106 => 3, 1107 => 3, 1201 => 2, 1202 => 2, 1203 => 2, 1204 => 2, 1205 => 2, 1206 => 2, 1207 => 2, 1301 => 1, 1302 => 1, 1303 => 1, 1304 => 1, 1305 => 1, 2101 => 3, 2102 => 3, 2103 => 3, 2104 => 3);
     $user->items = serialize($reward_items);
     $user->save();
     if (!isset($aid)) {
         $animal = new Animal();
         $animal->name = $name;
         $animal->gender = $gender;
         $animal->age = $age;
         $animal->type = $type;
         $animal->from = substr($type, 0, 1);
         $animal->master_id = $user->usr_id;
         $animal->save();
         $aid = $animal->aid;
         $circle = new Circle();
         $circle->aid = $aid;
         $circle->usr_id = $user->usr_id;
         $circle->rank = 0;
         $circle->save();
     } else {
         $circle = new Circle();
         $circle->aid = $aid;
         $circle->usr_id = $user->usr_id;
         $circle->save();
     }
     $f = new Follow();
     $f->usr_id = $user->usr_id;
     $f->aid = $aid;
     $f->create_time = time();
     $f->save();
     $user->aid = $aid;
     $user->saveAttributes(array('aid'));
     $user->initialize();
     $user->rewardInviter();
     //$this->onRegister = array($user, 'initialize');
     //$this->onRegister = array($user, 'rewardInviter');
     $this->owner->usr_id = $user->usr_id;
     $this->owner->saveAttributes(array('usr_id'));
     $this->onRegister(new CEvent());
     return $user;
 }
開發者ID:sr71k,項目名稱:pet,代碼行數:49,代碼來源:DeviceBehavior.php

示例7: getList

 function getList($pagina = 1, $orden = "", $nrpp = Constant::NRPP)
 {
     $ordenPredeterminado = "{$orden}, NombreAnimal, ZonaCode, IDAnimal";
     if ($orden === "" || $orden === null) {
         $ordenPredeterminado = "NombreAnimal, ZonaCode, IDAnimal";
     }
     $registroInicial = ($pagina - 1) * $nrpp;
     $this->bd->select($this->tabla, "*", "1=1", array(), $ordenPredeterminado, "{$registroInicial}, {$nrpp}");
     $r = array();
     while ($fila = $this->bd->getRow()) {
         $animal = new Animal();
         $animal->set($fila);
         $r[] = $animal;
     }
     return $r;
 }
開發者ID:jcfuentes102,項目名稱:ZOO,代碼行數:16,代碼來源:ManageAnimal.php

示例8: deleteAnimal

 public static function deleteAnimal($ìd)
 {
     try {
         Animal::delete($id);
         echo 'Animal excluído';
     } catch (PDOException $e) {
         echo 'Houve um erro: ' . $e;
     }
 }
開發者ID:vncdias,項目名稱:missao-simplesvet,代碼行數:9,代碼來源:AnimalController.php

示例9: getListCountryCityCountryLanguage

 function getListCountryCityCountryLanguage($condicion = null, $parametros = array())
 {
     if ($condicion === null) {
         $condicion = "";
     } else {
         $condicion = "where {$condicion}";
     }
     $sql = " select co.*, ci.*, cl.*\r\n                    from country co\r\n                    left join city ci\r\n                    on co.Code = ci.CountryCode\r\n                    left join countrylanguage cl \r\n                    on co.Code =  cl.CountryCode {$condicion}";
     $this->bd->send($sql, $parametros);
     $r = array();
     while ($fila = $this->bd->getRow()) {
         $country = new Cuidador();
         $country->set($fila);
         $city = new Animal();
         $city->set($fila, 15);
         $countrylanguage = new CountryLanguage();
         $countrylanguage->set($fila, 20);
         $r[] = new CountryCityCountryLanguage($country, $city, $countrylanguage);
     }
     return $r;
 }
開發者ID:jcfuentes102,項目名稱:ZOO,代碼行數:21,代碼來源:CountryCityCountryLanguage.php

示例10: testBatchWrite_NestedObjects_ObjectsExist

 /**
  *
  */
 public function testBatchWrite_NestedObjects_ObjectsExist()
 {
     $dogs = array();
     for ($i = 0; $i < 100; $i++) {
         $dog = new Dog();
         $dog->Name = 'Bob ' . $i;
         $dog->Country = 'Africa ' . $i;
         $dog->Type = 'Woof Dog ' . $i;
         $dog->Color = 'Brown #' . $i;
         $dogs[] = $dog;
     }
     $batch = new \Batch();
     $batch->write($dogs);
     for ($i = 0; $i < 100; $i++) {
         $this->assertTrue($dogs[$i]->exists());
         $id = $dogs[$i]->ID;
         $this->assertEquals($i + 1, $id);
     }
     $this->assertEquals(100, Dog::get()->count());
     foreach (Animal::get() as $i => $dog) {
         $this->assertEquals('Bob ' . $i, $dog->Name);
         $this->assertEquals('Brown #' . $i, $dog->Color);
     }
 }
開發者ID:helpfulrobot,項目名稱:littlegiant-silverstripe-batchwrite,代碼行數:27,代碼來源:BatchWriteTest.php

示例11: getHomelessAnimals

 /**
  * @return la liste des animaux à l'adoption
  */
 public static function getHomelessAnimals()
 {
     $db = DbManager::getPDO();
     $query = "SELECT * FROM Animal WHERE idState='" . self::$STATE_ADOPTION . "';";
     $res = $db->query($query)->fetchAll();
     for ($i = 0; $i < count($res); $i++) {
         $animal = Animal::getAnimalArrayFromFetch($res[$i]);
         $listAnimals[$animal['idAnimal']] = $animal;
     }
     return $listAnimals;
 }
開發者ID:Gouga34,項目名稱:Server,代碼行數:14,代碼來源:Animal.php

示例12: __autoload

<?php

function __autoload($className)
{
    require_once $className . '-class.php';
}
// ANIMAL CLASS
$kikker = new Animal('Kermit', 'male', 100);
$kat = new Animal('Dikkie', 'male', 100);
$kat->changeHealth(-10);
$dolfijn = new Animal('Flipper', 'female', 80);
?>


<!DOCTYPE html>
<html>
<head>
	<title>Oplossing PHPoefening 040</title>
</head>
	<body>
	

		<h1>Oplossing PHPoefening 040</h1>
		
		
		<p><?php 
echo $kikker->getName();
?>
 is van het geslacht <?php 
echo $kikker->getSex();
?>
開發者ID:gurbuzhasan,項目名稱:web-backend,代碼行數:31,代碼來源:phpoefening-040-a-oplossing.php

示例13: describe

 public function describe()
 {
     $parentValue = parent::describe();
     //$parentValue .= $this->ssn;
     return $parentValue . ' but I am really a dog';
     //return parent::describe();
 }
開發者ID:sameg14,項目名稱:php-mastery-code,代碼行數:7,代碼來源:animals.php

示例14: __construct

 public function __construct($name, $address)
 {
     // Call the parent constructor to save time
     parent::__construct($name);
     // Assign an additional value
     $this->address = $address;
 }
開發者ID:jorions,項目名稱:ACA_PHP_Intermediate,代碼行數:7,代碼來源:04-constructors.php

示例15: mostra

 public function mostra()
 {
     #Chamando função da classe pai.
     parent::mostra();
     echo "Alimento: " . $this->alimento . "</br>";
     echo "Som: " . $this->som . "</br>";
 }
開發者ID:leoallvez,項目名稱:PHP-lessons,代碼行數:7,代碼來源:classe-mamifero.php


注:本文中的Animal類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。