| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
|     61% | Total: 166 | All time:  8,899 This week: 74  | ||||
| Version | License | PHP version | Categories | |||
| hypersistence 2.0 | MIT/X Consortium ... | 5.0 | PHP 5, Databases, Design Patterns | 
| Description | Author | ||||||||
| This class can store and retrieve objects in databases using PDO. | 
 | 
PHP Object Orented persistence framework.
Use doc comment tags for mapping classes with database.
<h3>Example:</h3>
/
 * @table(person)
 */
class Person extends Hypersistence{
    
    /
     * @primaryKey
     * @column(person_id)
     */
    private $id;
    
    /
     * Use empty column when the column has the same name that var.
     * @column()
     */
    private $name;
    
    /
     * When you have a Many to One relationship use tags as below.
     * You can use 'lazy' or 'eager'.
     * @manyToOne(lazy)
     * @column(city_id)
     * @itemClass(City)
     */
    private $city;
    
    /
     * When you have a One to Many relationship use tags as below.
     * You can use 'lazy' or 'eager'.
     * @oneToMany(lazy)
     * @joinColumn(person_id)
     * @itemClass(Book)
     */
    private $books;
    
    /
     * When you have a Many to Many relationship use tags as below.
     * You can use 'lazy' or 'eager'.
     * @manyToMany(lazy)
     * @joinColumn(person_id)
     * @inverseJoinColumn(course_id)
     * @itemClass(Course)
     * @joinTable(person_has_course)
     */
    private $courses;
    
    public function getId(){
        return $this->id;
    }
    
    public function setId($id){
        $this->id = $id;
    }
    
    public function getName(){
        return $this->name;
    }
    
    public function setName($name){
        $this->name = $name;
    }
    
    public function getCity(){
        return $this->city;
    }
    
    public function setCity($city){
        $this->city = $city;
    }
    
    public function getBooks(){
        return $this->books;
    }
    
    public function getCourses(){
        return $this->courses;
    }
}
<h3>Load Example:</h3>
$p = new Person();
$p->setId(1);
$p->load();
echo $p->getName();
<h3>Save Example:</h3>
$p = new Person();
$p->setName('Mateus Fornari');
$city = new City(1);
$city->load();
$p->setCity($city);
$p->save();
<h3>Search Example:</h3>
$p = new Person();
$p->setName('Mateus');
$search = $p->search();
$search->orderBy('name', 'asc');
$search->orderBy('city.name', 'desc');
$list = $search->execute();
|  Files (16) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  src (2 directories) | ||||
|    composer.json | Data | Auxiliary data | ||
|    LICENSE.txt | Lic. | Documentation | ||
|    README.md | Doc. | Auxiliary data | ||
|  Files (16) | / | src | / | Example | 
| File | Role | Description | 
|---|---|---|
|    Book.php | Example | Example script | 
|    City.php | Example | Example script | 
|    Course.php | Example | Example script | 
|    db.sql | Data | Auxiliary data | 
|    index.php | Example | Example script | 
|    Person.php | Example | Example script | 
|    Student.php | Example | Example script | 
|  Files (16) | / | src | / | Hypersistence | 
| File | Role | Description | ||
|---|---|---|---|---|
|  Core (4 files) | ||||
|    dbconf.xml | Data | Auxiliary data | ||
|  Hypersistence.php | Class | Class source | ||
|  Files (16) | / | src | / | Hypersistence | / | Core | 
| File | Role | Description | 
|---|---|---|
|  DB.php | Class | Class source | 
|  Engine.php | Class | Class source | 
|  QueryBuilder.php | Class | Class source | 
|  Statement.php | Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| User Ratings | User Comments (2) | |||||||||||||||||||||||||||||||||||||
| 
 | 
 | |||||||||||||||||||||||||||||||||||||
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.
| Related pages | 
| GitHub repository | 
| Hypersistence documentation |