PHP Classes

File: test_model.php

Recommend this page to a friend!
  Classes of SzpaQ  >  Simple PHP Model Class  >  test_model.php  >  Download  
File: test_model.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP Model Class
Store and retrieve objects in databases using PDO
Author: By
Last change:
Date: 3 years ago
Size: 778 bytes
 

Contents

Class file image Download
<?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

For more information send a message to info at phpclasses dot org.