Example #1
0
 /**
  * 
  * @param string $view     
  * @param mixed $viewData 
  * @param array $composer  
  * @return mixed 
  */
 public function __construct($view, $viewData, $composers)
 {
     if (count($composers) != 0) {
         foreach ($composers as $composer) {
             $composer = new $composer();
             if ($composer->composerData != null) {
                 extract($composer->composerData);
             }
         }
     }
     if ($viewData != null) {
         extract($viewData);
     }
     $h = IoC::resolve('ViewHelper');
     $helper = IoC::resolve('Helper');
     ob_start();
     require_once path("application/views/{$view}.php");
     $layout = isset($layout) ? $layout : 'master';
     $view = ob_get_contents();
     ob_end_clean();
     ob_start();
     require_once path("application/views/layout/" . $layout . ".php");
     $output = ob_get_contents();
     ob_end_clean();
     Event::trigger('before_echo', array());
     return $this->output = $output;
 }
Example #2
0
 /**
  * 
  * @param string $query
  * @param array|null $array
  * @return int
  */
 public function write($query, $array = null)
 {
     Event::trigger('before_save', array());
     $stmt = $this->db->prepare($query);
     if (is_array($array)) {
         $stmt->execute($array);
     } else {
         $stmt->execute();
     }
     ModelAbstract::$query[] = $stmt->queryString;
     return $stmt->rowCount();
 }
Example #3
0
 /**
  * @param array|null $data
  * @return int
  */
 public function update(array $data = null)
 {
     Event::trigger('before_save', array());
     if (is_array($data)) {
         foreach ($data as $k => $v) {
             $this->{$k} = $v;
         }
     }
     ksort($this->_columns);
     $fieldDetails = null;
     foreach ($this->_columns as $key => $value) {
         $fieldDetails .= "{$key}=:{$key},";
     }
     $fieldDetails = rtrim($fieldDetails, ',');
     $sth = $this->_db->prepare("UPDATE {$this->table} SET {$fieldDetails} {$this->_where}");
     foreach ($this->_columns as $key => $value) {
         $sth->bindValue(":{$key}", $value);
     }
     $sth->bindValue(key($this->_array_where), $this->_array_where[key($this->_array_where)]);
     $exec = $sth->execute();
     self::$query[] = $sth->queryString;
     $this->__clear();
     if (($rowCount = $sth->rowCount()) > 0) {
         return $rowCount;
     } elseif ($exec) {
         return true;
     }
     return false;
 }