PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 155 All time: 9,006 This week: 194Up
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: 302771 in Poland Poland
Week rank: 388 Up10 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  
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  /  self_stand  
File Role Description
  Plain text file Model.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:155
This week:0
All time:9,006
This week:194Up