cvs: presentations /slides/mvc/example/model db.phps items.phps
| From: | Rasmus Lerdorf | Date: | Sat, 11 Mar 2006 08:36:57 +0000 |
| Subject: | cvs: presentations /slides/mvc/example/model db.phps items.phps | ||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1268@lists.php.net to get a copy of this message | ||
rasmus Sat Mar 11 08:36:57 2006 UTC
Modified files:
/presentations/slides/mvc/example/model db.phps items.phps
Log:
These should be symlinks
http://cvs.php.net/viewcvs.cgi/presentations/slides/mvc/example/model/db.phps?r1=1.2&r2=1.3&diff_format=u
Index: presentations/slides/mvc/example/model/db.phps
diff -u presentations/slides/mvc/example/model/db.phps:1.2
presentations/slides/mvc/example/model/db.phps:1.3
--- presentations/slides/mvc/example/model/db.phps:1.2 Thu Mar 2 04:11:06 2006
+++ presentations/slides/mvc/example/model/db.phps Sat Mar 11 08:36:57 2006
@@ -1,11 +1,11 @@
<?php
class db {
- public $dbh = false;
+ protected static $dbh = false;
function connect() {
- $this->dbh = new PDO('sqlite:./model/example.db');
- $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ self::$dbh = new PDO('sqlite:./model/example.db');
+ self::$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
protected function fatal_error($msg) {
http://cvs.php.net/viewcvs.cgi/presentations/slides/mvc/example/model/items.phps?r1=1.3&r2=1.4&diff_format=u
Index: presentations/slides/mvc/example/model/items.phps
diff -u presentations/slides/mvc/example/model/items.phps:1.3
presentations/slides/mvc/example/model/items.phps:1.4
--- presentations/slides/mvc/example/model/items.phps:1.3 Thu Mar 2 04:11:06 2006
+++ presentations/slides/mvc/example/model/items.phps Sat Mar 11 08:36:57 2006
@@ -11,8 +11,8 @@
function insert($item) {
$t = $_SERVER["REQUEST_TIME"];
try {
- if(!$this->dbh) $this->connect();
- $stmt = $this->dbh->prepare("INSERT INTO items
+ if(!self::$dbh) $this->connect();
+ $stmt = self::$dbh->prepare("INSERT INTO items
(id,cat,sdesc,ldesc,price,ctime)
VALUES
(NULL,:cat,:sdesc,:ldesc,:price,$t)");
@@ -29,8 +29,8 @@
function modify($item) {
try {
- if(!$this->dbh) $this->connect();
- $stmt = $this->dbh->prepare("UPDATE items SET
+ if(!self::$dbh) $this->connect();
+ $stmt = self::$dbh->prepare("UPDATE items SET
cat=:cat, sdesc=:sdesc,
ldesc=:ldesc, price=:price
WHERE id=:id");
@@ -51,8 +51,8 @@
if($id!=-1) $where = "where id=".(int)$id;
try {
- if(!$this->dbh) $this->connect();
- $result = $this->dbh->query("SELECT * FROM items
+ if(!self::$dbh) $this->connect();
+ $result = self::$dbh->query("SELECT * FROM items
$where order by ctime desc");
$rows = $result->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {