Public Member Functions | |
__construct (StorageProviderInterface $storage) | |
persist ($account) | |
retrieve ($username) | |
delete ($object) | |
retrieveById (string $id) | |
Public Member Functions inherited from snuze\SnuzeObject | |
__construct (array $args=null) | |
_getSnuzeId () | |
_getSnuzeClass () | |
_ident () | |
Private Attributes | |
$pdo = null | |
Additional Inherited Members | |
Protected Member Functions inherited from snuze\SnuzeObject | |
debug (string $message, bool $echo=false) | |
info (string $message, bool $echo=false) | |
warning (string $message, bool $echo=false) | |
error (string $message, bool $echo=false) | |
Protected Attributes inherited from snuze\SnuzeObject | |
$_snuzeId = null | |
$_snuzeClass = null | |
A data mapper class for Account subtype objects using the MySQL StorageProvider.
This is where abstraction goes to die.
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\AccountMapper::__construct | ( | StorageProviderInterface | $storage | ) |
\snuze\Persistence\MySQL\StorageProvider | $storage | A MySQL StorageProvider object |
Implements snuze\Persistence\Interfaces\MapperInterface.
snuze\Persistence\MySQL\AccountMapper::delete | ( | $object | ) |
Delete an account from the database.
\snuze\Reddit\Thing\Account\Account | $object | The account to delete |
Implements snuze\Persistence\Interfaces\MapperInterface.
snuze\Persistence\MySQL\AccountMapper::persist | ( | $account | ) |
Insert or update an Account subtype to the MySQL database.
If a MyAccount object is supplied, only the properties associated with a UserAccount are persisted; attributes that are specific to MyAccount won't be stored.
\snuze\Reddit\Thing\Account\Account | $account | The account to persist |
Implements snuze\Persistence\Interfaces\MapperInterface.
snuze\Persistence\MySQL\AccountMapper::retrieve | ( | $username | ) |
Get an account from the database by its username.
string | $username | The username of the account to retrieve |
Boolean fields are stored as BIT (0 or 1) in the database. Snuze expects booleans, and uses strict typing. Here the 0s and 1s are massaged back to boolean values.
Array fields are stored in the database as JSON-encoded strings. Here they're massaged back into arrays so json_encode() (below) doesn't double-encode them.
Reddit provides epoch timestamps as floats. They're stored in the database as integers. Here they're massaged back into floats.
Implements snuze\Persistence\Interfaces\AccountMapperInterface.
snuze\Persistence\MySQL\AccountMapper::retrieveById | ( | string | $id | ) |
Get an account from the database by its Reddit internal ID. This incurs an extra query penalty, as it first looks up the corresponding username and then calls retrieve() to do the heavy lifting.
string | $id | The Reddit internal ID (e.g. "bva2") of the account to retrieve |
Implements snuze\Persistence\Interfaces\AccountMapperInterface.
References snuze\Persistence\MySQL\AccountMapper\retrieve().