/** * DB connection for meta data. * * @param ConnectionInterface $conn */ public function __construct(ConnectionInterface $conn) { parent::__construct(); $this->conn = $conn; if (mt_rand(0, 100) > 95) { $stmt = $conn->prepare("DELETE FROM `#__webdav_lock` WHERE `expires_at` < :time"); $stmt->bindValue('time', time()); $stmt->execute(); } }
protected function bindEncodedParams() { foreach ($this->params as $k => $v) { $encoded = false; foreach ($this->encoders as $encoder) { $result = $encoder->encodeParam($this->conn, $v, $encoded); if ($encoded) { $v = $result; break; } } if ($v instanceof StreamInterface) { if (!$v->isReadable()) { throw new \InvalidArgumentException('Input stream must be readable to be used as DB input param'); } // FIXME: This is a workaround for PHP7 crashing with Sqlite LOB params bound to input streams... if ($this->conn->getDriverName() == DB::DRIVER_SQLITE && defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION > 5) { $this->stmt->bindValue($k, $v->getContents()); } else { $this->stmt->bindValue($k, (new StreamWrapper($v))->getResource(), \PDO::PARAM_LOB); } } elseif ($v instanceof UUID) { switch ($this->conn->getDriverName()) { case DB::DRIVER_MSSQL: case DB::DRIVER_POSTGRESQL: $this->stmt->bindValue($k, (string) $v); break; default: $this->stmt->bindValue($k, $v->toBinary()); } } else { $this->stmt->bindValue($k, $v); } } }
protected function syncVariables(Execution $execution, array $syncData) { $delta = $this->computeVarDelta($execution, $syncData); if (!empty($delta[Execution::SYNC_STATE_REMOVED])) { $this->conn->delete('#__bpmn_execution_variables', ['execution_id' => $execution->getId(), 'name' => (array) $delta[Execution::SYNC_STATE_REMOVED]]); } if (!empty($delta[Execution::SYNC_STATE_MODIFIED])) { foreach ($delta[Execution::SYNC_STATE_MODIFIED] as $k) { $value = NULL; if (is_scalar($syncData['variables'][$k])) { $val = $syncData['variables'][$k]; if (is_bool($val)) { $val = $val ? '1' : '0'; } $value = new UnicodeString(trim($val)); if ($value->length() > 250) { $value = $value->substring(0, 250); } $value = $value->toLowerCase(); } $this->conn->insert('#__bpmn_execution_variables', ['execution_id' => $execution->getId(), 'name' => $k, 'value' => $value, 'value_blob' => new BinaryData(serialize($syncData['variables'][$k]))]); } } }
public function __construct(ConnectionInterface $conn, \DateTimeInterface $date = NULL) { $this->conn = $conn; $this->platform = $conn->getPlatform(); $this->date = $date === NULL ? new \DateTime('@0') : clone $date; }