Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 31st, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. namespace App\Model;
  3. use PPI\Core;
  4. class Demo {
  5.        
  6.         protected $_table = 'demo';
  7.         protected $_primary = 'id';
  8.         protected $_conn = null;
  9.        
  10.         function __construct() {
  11.                
  12.                 $this->_conn = Core::getDataSourceConnection('main');
  13.                
  14.         }
  15.        
  16.         function getAll() {
  17.                 return $this->_conn->query("SELECT * FROM {$this->_table}")->fetchAll(\PDO::FETCH_ASSOC);
  18.         }
  19.        
  20.         function insert($data) {
  21.                 $this->_conn->insert($this->_table, $data);
  22.                 return $this->_conn->lastInsertId();
  23.         }
  24.        
  25.         function delete($where) {
  26.                 return $this->_conn->delete($this->_table, $where);
  27.         }
  28.        
  29.         function update($data, $where) {
  30.                 return $this->_conn->update($this->_table, $data, $where);
  31.         }
  32.        
  33. }