本文整理汇总了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);
}
示例2: perigo
public function perigo(Animal $p)
{
$p->emitirSom();
$p->dormir();
//$p->brincar(); Nao vale para todos
//os animais.
}
示例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;
}
示例4: removeAnimal
public function removeAnimal(Animal $animal)
{
foreach ($this->_group as $key => $current) {
if ($current->getAnimalName() == $animal->getAnimalName()) {
unset($this->_group[$key]);
}
}
}
示例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));
}
}
}
示例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;
}
示例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;
}
示例8: deleteAnimal
public static function deleteAnimal($ìd)
{
try {
Animal::delete($id);
echo 'Animal excluído';
} catch (PDOException $e) {
echo 'Houve um erro: ' . $e;
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
?>
示例13: describe
public function describe()
{
$parentValue = parent::describe();
//$parentValue .= $this->ssn;
return $parentValue . ' but I am really a dog';
//return parent::describe();
}
示例14: __construct
public function __construct($name, $address)
{
// Call the parent constructor to save time
parent::__construct($name);
// Assign an additional value
$this->address = $address;
}
示例15: mostra
public function mostra()
{
#Chamando função da classe pai.
parent::mostra();
echo "Alimento: " . $this->alimento . "</br>";
echo "Som: " . $this->som . "</br>";
}