lithium\data\source\database\adapter\MySql::strict()

public method

Enables/disables or retrieves strictness setting.

This method will only operate on session level, it will not check/set global settings. STRICT_ALL_TABLES mode is used to enable strict mode.

Parameters

  • boolean|null $value

    true to enable strict mode, false to disable or null to retrieve the current setting.

Returns

boolean

When setting, returns true on success, else false. When $value was null return either true or false indicating whether strict mode is enabled or disabled.

Source

	public function strict($value = null) {
		if ($value === null) {
			return strpos(
				$this->connection->query('SELECT @@SESSION.sql_mode')->fetchColumn(),
				'STRICT_ALL_TABLES'
			) !== false;
		}
		if ($value) {
			$sql = "SET SESSION sql_mode = 'STRICT_ALL_TABLES'";
		} else {
			$sql = "SET SESSION sql_mode = ''";
		}
		return $this->connection->exec($sql) !== false;
	}