/** * Write method * * Saves session data, takes session id and data to be save as its * parameters. The "write" handler is not executed until after the output * stream is closed. Thus, output from debugging statements in the "write" * handler will never be seen in the browser. If debugging output is * necessary, it is suggested that the debug output be written to a file * instead. * * <b>NOTE:</b> Because PHP first destroys all unused objects and then tries * to write session data, you cannot use a database driver, * which disconnects from the database in the destructor. * * <b>NOTE:</b> Because PHP removes all autoload functions from autoload * stack, this function relies on all the required classes to * be loaded already. * * * @param string $id * @param string $data * * @return bool */ public function write($id, $data) { require_once 'ae' . SLASH . 'classes' . SLASH . 'date.class.php'; require_once 'ae' . SLASH . 'classes' . SLASH . 'date' . SLASH . 'timezone.class.php'; $data = new AeNode(array('id' => $id, 'data' => $data, 'date' => AeDate::now('UTC'))); if ($this->fireEvent('write', $data)) { $db = $this->getConnection(); $query = $db->queryObject(); $data = $data->getProperties(); $data['date'] = $data['date']->getValue('Y-m-d H:i:s'); // *** Bind all data foreach ($data as $field => $value) { $data[$field] = $query->bind($field, $value); } $query->replace($this->_storageTable)->values($data)->execute(); return true; } return false; }
/** * Set timezone * * Returns a date with a different timezone set and the date's time properly * adjusted. This is useful to convert a date to be displayed for a user * with a different timezone setting. * * See {@link AeDate_Timezone::setValue()} method for a detailed overview of * accepted values * * @param AeDate_Timezone|DateTimeZone|string $value * * @return AeDate */ public function setTimezone($value = null) { if (!$value instanceof AeDate_Timezone) { $value = AeDate::timezone($value); } $zone = $value->getValue(); if (strpos($zone, ' ') !== false) { $zone = str_replace(' ', '_', $zone); } $zone = @timezone_open($zone); $date = $this->_value; $date->setTimezone($zone); return new AeDate($date, $value); }