当前位置: 首页>>代码示例>>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;未经允许,请勿转载。