PHP Classes

Hypersistence: Store and retrieve objects in databases using PDO

Recommend this page to a friend!
  Info   View files Documentation   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 69%Total: 164 This week: 1All time: 8,898 This week: 89Up
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: 41
All time rank: 4239346 in Brazil Brazil
Week rank: 91 Up6 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  
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  /  src  
File Role Description
Files folder imageExample (7 files)
Files folder imageHypersistence (2 files, 1 directory)

  Files folder image Files  /  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  /  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  /  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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:164
This week:1
All time:8,898
This week:89Up
User Ratings User Comments (2)
 All time
Utility:91%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:83%StarStarStarStarStar
Tests:-
Videos:-
Overall:69%StarStarStarStar
Rank:356
 
I'm using the Hypersistence classes and is very very good.
9 years ago (José Batista Pereira)
77%StarStarStarStar
Very gooood!!!!
9 years ago (Thiago José)
80%StarStarStarStarStar