PHP Classes

Hypersistence: Store and retrieve objects in databases using PDO

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 61%Total: 166 All time: 8,898 This week: 74Up
Version License PHP version Categories
hypersistence 2.0MIT/X Consortium ...5.0PHP 5, Databases, Design Patterns
Description 

Author

This class can store and retrieve objects in databases using PDO.

It provides base classes that implement the process of storing and retrieving objects defined by subclasses, its variables and comments that specify how to map the class variables to database table fields.

It uses PDO to access the database server using parameters retrieved from a configuration XML file.

Picture of Mateus Fornari
  Performance   Level  
Name: Mateus Fornari <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 42
All time rank: 4245347 in Brazil Brazil
Week rank: 216 Up20 in Brazil Brazil Up

Documentation

Hypersistence2.0

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 folder image Files (16)  
File Role Description
Files folder imagesrc (2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Lic. Documentation
Accessible without login Plain text file README.md Doc. Auxiliary data

  Files folder image Files (16)  /  src  
File Role Description
Files folder imageExample (7 files)
Files folder imageHypersistence (2 files, 1 directory)

  Files folder image Files (16)  /  src  /  Example  
File Role Description
  Accessible without login Plain text file Book.php Example Example script
  Accessible without login Plain text file City.php Example Example script
  Accessible without login Plain text file Course.php Example Example script
  Accessible without login Plain text file db.sql Data Auxiliary data
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file Person.php Example Example script
  Accessible without login Plain text file Student.php Example Example script

  Files folder image Files (16)  /  src  /  Hypersistence  
File Role Description
Files folder imageCore (4 files)
  Accessible without login Plain text file dbconf.xml Data Auxiliary data
  Plain text file Hypersistence.php Class Class source

  Files folder image Files (16)  /  src  /  Hypersistence  /  Core  
File Role Description
  Plain text file DB.php Class Class source
  Plain text file Engine.php Class Class source
  Plain text file QueryBuilder.php Class Class source
  Plain text file 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 Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:166
This week:0
All time:8,898
This week:74Up
User Ratings User Comments (2)
 All time
Utility:81%StarStarStarStarStar
Consistency:68%StarStarStarStar
Documentation:68%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:61%StarStarStarStar
Rank:984
 
I'm using the Hypersistence classes and is very very good.
10 years ago (José Batista Pereira)
77%StarStarStarStar
Very gooood!!!!
10 years ago (Thiago José)
80%StarStarStarStarStar