- update for PHP 5.4 compatibility

- reformat source to PSR-2 standard
This commit is contained in:
Uwe.Tews@googlemail.com
2013-07-14 22:15:45 +00:00
parent f99e6a83ce
commit 00ccae8857
126 changed files with 5232 additions and 5186 deletions

View File

@@ -20,7 +20,8 @@
* @package Resource-examples
* @author Rodney Rehm
*/
class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{
// PDO instance
protected $db;
// prepared fetch() statement
@@ -28,7 +29,8 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
// prepared fetchTimestamp() statement
protected $mtime;
public function __construct() {
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
} catch (PDOException $e) {
@@ -37,13 +39,13 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
$this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name');
}
/**
* Fetch a template and its modification time from database
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @return void
*/
protected function fetch($name, &$source, &$mtime)
@@ -59,18 +61,20 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
$mtime = null;
}
}
/**
* Fetch a template's modification time from database
*
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
* @param string $name template name
* @param string $name template name
* @return integer timestamp (epoch) the template was modified
*/
protected function fetchTimestamp($name) {
protected function fetchTimestamp($name)
{
$this->mtime->execute(array('name' => $name));
$mtime = $this->mtime->fetchColumn();
$this->mtime->closeCursor();
return strtotime($mtime);
}
}