PHP Classes

Simple PHP Model Class: Store and retrieve objects in databases using PDO

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 156 All time: 9,014 This week: 455Up
Version License PHP version Categories
simplemodel 1.0.0The PHP License5PHP 5, Databases, Design Patterns
Description 

Author

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

It provides a base class that can be extend by implementation model classes that can perform several types of operations with objects that are stored in a database accessed using the PDO extension.

Currently the base model class can:

- Establish hasOne and hasMany relationships with other model classes
- Manage transactions
- Find or count objects that match given conditions
- Save or delete objects
- Retrieve existing model structure reading a given database schema
- Access class properties using getter and setter functions
- Etc..

Picture of SzpaQ
  Performance   Level  
Name: SzpaQ <contact>
Classes: 5 packages by
Country: Poland Poland
Age: ???
All time rank: 300570 in Poland Poland
Week rank: 164 Up4 in Poland Poland Up

Example

<?php
/**
 * @author ?ukasz Szpak ( szpaaaaq@gmail.com )
 * @Copyright 2018 SzpaQ
 * @license ALL RIGHTS RESERVED
 * */

require_once 'self_stand/Model.php';
class
Users extends Model {
    public function
initialize()
    {
       
$this->hasMany('user_id', 'Task');
    }
}
class
Task extends Model {
    public function
initialize()
    {

    }
}

Model::_setDB(array(
   
'host' => 'localhost',
   
'name' => 'dev_crm',
   
'user' => 'szpak',
   
'pass' => 'x',
   
'charset' => 'utf8',
   
'prefix' => 'sh_',
));

Model::transaction();
$user = Users::findFirst(2);
$task = new Task;
$task->save();
$user -> username = 'SzpaQ';
$user->save();
Model::commit(); // Transaction won't be committed since task wont be save. It suppose to have few properties like user_id, name


  Files folder image Files (2)  
File Role Description
Files folder imageself_stand (1 file)
Accessible without login Plain text file test_model.php Example Example script

  Files folder image Files (2)  /  self_stand  
File Role Description
  Plain text file Model.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:156
This week:0
All time:9,014
This week:455Up