connection->getType()) { case DatabaseType::MYSQL: $query = new Builder($this->connection); $sql = $query->select(...static::$columns) ->from($this->connection->prefix . static::$table) ->where(static::$columns[0], 'in', $columns) ->toSql(); $sth = $this->connection->con->prepare($sql); $sth->execute(); $options = $sth->fetchAll(\PDO::FETCH_KEY_PAIR); $this->setOptions($options); break; } return count($options) > 1 ? $options : reset($options); } catch (\PDOException $e) { $exception = DatabaseExceptionFactory::createException($e); $message = DatabaseExceptionFactory::createExceptionMessage($e); throw new $exception($message); } } /** * Set option by key. * * @param string[] $options Column values for filtering * @param bool $store Save this Setting immediately to database * * @return void * * @since 1.0.0 */ public function set(array $options, bool $store = false) : void { $this->setOptions($options); if ($store) { foreach ($this->options as $key => $option) { $query = new Builder($this->connection); $sql = $query->update($this->connection->prefix . static::$table) ->set([static::$columns[1] => $option]) ->where(static::$columns[0], '=', $key) ->toSql(); $sth = $this->connection->con->prepare($sql); $sth->execute(); } } } }