
Untitled
By: a guest on
May 31st, 2012 | syntax:
None | size: 0.64 KB | hits: 11 | expires: Never
<?php
namespace App\Model;
use PPI\Core;
class Demo {
protected $_table = 'demo';
protected $_primary = 'id';
protected $_conn = null;
function __construct() {
$this->_conn = Core::getDataSourceConnection('main');
}
function getAll() {
return $this->_conn->query("SELECT * FROM {$this->_table}")->fetchAll(\PDO::FETCH_ASSOC);
}
function insert($data) {
$this->_conn->insert($this->_table, $data);
return $this->_conn->lastInsertId();
}
function delete($where) {
return $this->_conn->delete($this->_table, $where);
}
function update($data, $where) {
return $this->_conn->update($this->_table, $data, $where);
}
}