Public Member Functions | |
__construct (array $configurationParameters=[]) | |
init () | |
getPdo () | |
![]() | |
getMapper (string $objectClass) | |
getRequiredExtensionNames () | |
init () | |
![]() | |
__construct (array $args=null) | |
_getSnuzeId () | |
_getSnuzeClass () | |
_ident () | |
Public Attributes | |
const | REQUIRED_EXTS = ['pdo_mysql'] |
const | SCHEMA_DIR = __DIR__ . '/schema' |
const | SCHEMA_VERSION = 1000801 |
Private Member Functions | |
validateSchema () | |
Private Attributes | |
$server = null | |
$username = null | |
$password = null | |
$database = null | |
$pdo = null | |
Additional Inherited Members | |
![]() | |
debug (string $message, bool $echo=false) | |
info (string $message, bool $echo=false) | |
warning (string $message, bool $echo=false) | |
error (string $message, bool $echo=false) | |
![]() | |
$_snuzeId = null | |
$_snuzeClass = null | |
![]() | |
static | $mappers = [] |
This is the MySQL storage provider class. It provides the functionality required for Snuze to talk to a MySQL database via PDO.
If you want to develop your own Snuze storage provider, looking here is a good place to start. Your storage provider needs to:
This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey shaun @sha unc.c omhttps://shaunc.com/ Repository: https://github.com/snuze/snuze/ Documentation: https://snuze.shaunc.com/
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
snuze\Persistence\MySQL\StorageProvider::__construct | ( | array | $configurationParameters = [] | ) |
Creates a new MySQL\StorageProvider object.
You must pass an array with four elements whose keys are 'server', 'username', 'password', and 'database', and whose values will be used to establish a PDO connection to MySQL.
string[] | $configurationParameters An array with elements named 'server', 'username', 'password', and 'database' |
Implements snuze\Persistence\Interfaces\StorageProviderInterface.
snuze\Persistence\MySQL\StorageProvider::getPdo | ( | ) |
Get the PDO object
snuze\Persistence\MySQL\StorageProvider::init | ( | ) |
Open a PDO handle to the database and test for the expected schema version. If the schema is outdated or doesn't exist yet, the user is prompted to run the included utility script, which will install or upgrade the schema as needed.
Implements snuze\Persistence\Interfaces\StorageProviderInterface.
References snuze\Persistence\MySQL\StorageProvider\validateSchema().
|
private |
Called by init().
Test for the presence of the "snuze" table in the database, and that its "schema_version" field matches self::SCHEMA_VERSION. If this fails, ask the user to go run the utility script to either install or upgrade the database schema.
This is specific to the MySQL storage provider. If implementing your own storage provider, you're welcome to mirror this design, but it's not a required feature of a Snuze storage provider in general.
References snuze\Persistence\MySQL\StorageProvider\SCHEMA_VERSION.
const snuze\Persistence\MySQL\StorageProvider::REQUIRED_EXTS = ['pdo_mysql'] |
PHP extensions required by this storage provider
const snuze\Persistence\MySQL\StorageProvider::SCHEMA_DIR = __DIR__ . '/schema' |
The directory containing .sql DDL files that define the base MySQL schema and the inter-version patches.
This is specific to the MySQL storage provider. If implementing your own storage provider, you're welcome to mirror this design, but it's not a required feature of a Snuze storage provider in general.
const snuze\Persistence\MySQL\StorageProvider::SCHEMA_VERSION = 1000801 |
The schema version number that this version of the MySQL storage provider expects to be working with. This will always be the build number of Snuze when schema changes were last made.
This is specific to the MySQL storage provider. If implementing your own storage provider, you're welcome to mirror this design, but it's not a required feature of a Snuze storage provider in general.