예제 #1
0
 /**
  * fake for test
  */
 public function findOne($con = null)
 {
     if (true === $this->bySlug) {
         $book = new Book();
         $book->setId(1);
         $book->setName('My Book');
         $book->setSlug('my-book');
         return $book;
     }
     return null;
 }
예제 #2
0
파일: books.php 프로젝트: kfiatos/Bookstore
function handlePUT()
{
    $conn = Connection::startConnection();
    parse_str(file_get_contents("php://input"), $data);
    header('Content-type: application/json');
    $book = new Book();
    $book->setName($data['name']);
    $book->setAuthor($data['author']);
    $book->setDesc($data['opis']);
    $book->updateBook($conn, $data['id']);
    Connection::stopConnecion($conn);
}
예제 #3
0
 public function findOrCreateOne($book_name)
 {
     # Attempt to find book
     $book = BookQuery::create()->filterByName($book_name)->findOne();
     # Return or create book
     if ($book) {
         return $book;
     } else {
         $book = new Book();
         $book->setName($book_name)->save();
         return $book;
     }
 }
예제 #4
0
파일: Ebook.php 프로젝트: kabaj/opp
 public function setName($newName)
 {
     parent::setName($newName . " - wersja cyfrowa");
 }
예제 #5
0
<?php

trait NameTrait
{
    private $name;
    public function getName()
    {
        return $this->name;
    }
    public function setName($name)
    {
        return $this->name = $name;
    }
}
class Book
{
    use NameTrait;
}
$book = new Book();
$book->setName('PHP Cookbook');
print $book->getName();