Snuze  0.8.1
snuze\Persistence\MySQL\LinkMapper Class Reference
Inheritance diagram for snuze\Persistence\MySQL\LinkMapper:

Public Member Functions

 __construct (StorageProviderInterface $storage)
 
 persist ($link)
 
 retrieve ($id)
 
 delete ($object)
 
- 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
 

Detailed Description

A data mapper class for Link 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.nosp@m.@sha.nosp@m.unc.c.nosp@m.om https://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.

Constructor & Destructor Documentation

◆ __construct()

snuze\Persistence\MySQL\LinkMapper::__construct ( StorageProviderInterface  $storage)
Parameters
\snuze\Persistence\MySQL\StorageProvider$storageA MySQL StorageProvider object
Exceptions

Implements snuze\Persistence\Interfaces\MapperInterface.

Member Function Documentation

◆ delete()

snuze\Persistence\MySQL\LinkMapper::delete (   $object)

Delete a Link from the database.

Parameters
\snuze\Reddit\Thing\Link$objectThe Link to delete
Returns
bool True on success; otherwise, an exception is thrown
Exceptions

Implements snuze\Persistence\Interfaces\MapperInterface.

◆ persist()

snuze\Persistence\MySQL\LinkMapper::persist (   $link)

Insert or update a Link to the MySQL database.

Parameters
\snuze\Reddit\Thing\Link$linkThe Link to persist
Returns
bool True on success; otherwise, an exception is thrown
Exceptions

Implements snuze\Persistence\Interfaces\MapperInterface.

◆ retrieve()

snuze\Persistence\MySQL\LinkMapper::retrieve (   $id)

Get a Link from the database by its id.

Parameters
string$idThe Reddit internal identifier (e.g. "5bx4bx") of the Link to retrieve
Returns
\snuze\Reddit\Thing\Link|null

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\MapperInterface.


The documentation for this class was generated from the following file: