/**
  * Write session data
  * @link http://php.net/manual/en/sessionhandlerinterface.write.php
  * @param string $session_id The session id.
  * @param string $session_data <p>
  * The encoded session data. This data is the
  * result of the PHP internally encoding
  * the $_SESSION superglobal to a serialized
  * string and passing it as this parameter.
  * Please note sessions use an alternative serialization method.
  * </p>
  * @return bool <p>
  * The return value (usually TRUE on success, FALSE on failure).
  * Note this value is returned internally to PHP for processing.
  * </p>
  * @since 5.4.0
  */
 public function write($session_id, $session_data)
 {
     $count = $this->database->read($this->table, function (Read $read) use($session_id) {
         return $read->where([['key', '=', $session_id]])->build();
     });
     if (!$count->rowCount()) {
         $return = $this->database->insert($this->table, function (Insert $insert) use($session_id, $session_data) {
             return $insert->set(['key' => $session_id, 'value' => $session_data])->build()->run();
         });
     } else {
         $return = $this->database->update($this->table, function (Update $update) use($session_id, $session_data) {
             return $update->where([['key', '=', $session_id]])->set(['value' => $session_data])->run();
         });
     }
     return $return ? true : false;
 }
Пример #2
0
 /**
  * Mysql üzerinde güncelleme işlemi yapar
  *
  * @return mixed
  */
 public function update()
 {
     $app = $this;
     return $this->db->update($this->table, function (Update $mode) use($app) {
         if (isset($app->where)) {
             $mode->where($app->where);
         }
         if (isset($app->set)) {
             $mode->set($app->set);
         }
         return $mode->run();
     });
 }