Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1893,4 +1893,34 @@ public function updateObject($table, &$object, $key, $nulls = false)

return true;
}

/**
* Get value of boolean session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return boolean|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarBool($name)
{
return null;
}

/**
* Get value of string session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return string|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarString($name)
{
return null;
}
}
24 changes: 24 additions & 0 deletions src/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,28 @@ public function unlockTables();
* @throws \RuntimeException
*/
public function updateObject($table, &$object, $key, $nulls = false);

/**
* Get value of boolean session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return boolean|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarBool($name);

/**
* Get value of string session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return string|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarString($name);
}
38 changes: 38 additions & 0 deletions src/Mysql/MysqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,4 +804,42 @@ public function transactionStart($asSavepoint = false)
}
}
}

/**
* Get value of boolean session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return boolean|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarBool($name)
{
$this->connect();

$result = $this->setQuery('SELECT @@' . $name . ';')->loadResult();

return $result === null ? null : (bool) $result;
}

/**
* Get value of string session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return string|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarString($name)
{
$this->connect();

$result = $this->setQuery('SELECT @@' . $name . ';')->loadResult();

return $result === null ? null : (string) $result;
}
}
38 changes: 38 additions & 0 deletions src/Mysqli/MysqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1082,4 +1082,42 @@ public function getNullDate()

return $this->nullDate;
}

/**
* Get value of boolean session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return boolean|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarBool($name)
{
$this->connect();

$result = $this->setQuery('SELECT @@' . $name . ';')->loadResult();

return $result === null ? null : (bool) $result;
}

/**
* Get value of string session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return string|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarString($name)
{
$this->connect();

$result = $this->setQuery('SELECT @@' . $name . ';')->loadResult();

return $result === null ? null : (string) $result;
}
}
38 changes: 38 additions & 0 deletions src/Pgsql/PgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,4 +1063,42 @@ public function decodeBinary($data)

return $data;
}

/**
* Get value of boolean session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return boolean|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarBool($name)
{
$this->connect();

$result = $this->setQuery('SELECT current_setting(\'' . $name . '\', true);')->loadResult();

return $result === null ? null : (bool) $result;
}

/**
* Get value of string session variable with the given name.
* Returns null if database doesn't support session variables or variable doesn't exist.
*
* @param string $name The name of the session variable.
*
* @return string|null
*
* @since __DEPLOY_VERSION__
*/
public function getSessionVarString($name)
{
$this->connect();

$result = $this->setQuery('SELECT current_setting(\'' . $name . '\', true);')->loadResult();

return $result === null ? null : (string) $result;
}
}