\JSONReader

A JSON Reader, storage using json files, as defined in Reader.

A index is a array of json keys: { "a" : { "b" : 12 } } ["a", "b"] => 12

Summary

Methods
Properties
Constants
changePath()
deleteFile()
getArray()
setArray()
output()
isValue()
getValue()
searchValue()
setValue()
__construct()
__destruct()
No public properties found
No constants found
No protected methods found
$path
N/A
write_content()
setValueHelper()
$filehandler
$data
$filepath
$datahash
$writeable
N/A

Properties

$path

$path : 

Path where the JSON files are located, in redis used as key prefix

Type

$filehandler

$filehandler : 

Type

$data

$data : 

Type

$filepath

$filepath : 

Type

$datahash

$datahash : 

Type

$writeable

$writeable : 

Type

Methods

changePath()

changePath(  $path = '') : \the

Changes the data path, the path on filesystem

Parameters

$path

the new path (optional)

Returns

\the —

current path

deleteFile()

deleteFile(\string  $name) : \deleted?

Deletes a JSON file. (needs exclusive rights)

Parameters

\string $name

file to delete

Returns

\deleted?

getArray()

getArray() : \the

Returns the array of this dataset

Returns

\the —

array

setArray()

setArray(array  $data) : \successful

Sets the array of this dataset

Parameters

array $data

Returns

\successful —

changed?

output()

output() 

Print the array

isValue()

isValue(array  $index,   $value = null) : \$value

Checks if a key has a value.

Parameters

array $index

array of indexes, the index

$value

the value need at index

Returns

\$value —

and value at $index matches, or $index exists

getValue()

getValue(array  $index, \bool  $exception = false) : \the

Fetch a value by the index

Parameters

array $index

the array of indexes, the index

\bool $exception

throw an exception if index not found, or return false (optional)

Returns

\the —

value or false

searchValue()

searchValue(  $index,   $value,   $column = null) : \like

Search a value.

Parameters

$index

$index the array of indexes, the index

$value

the value to search

$column

search a colum, name here or null (optional)

Returns

\like —

array_search(), the first found index or false

setValue()

setValue(array  $index,   $value) 

Set a value.

Parameters

array $index

array of indexes, the index

$value

the value to set

__construct()

__construct(  $filename,   $lockex = false,   $otherpath = '') 

Creates a JSON Reader, opens and imports file if files exists.

else creates a new file. Opens parent::$path/$filename, $filename contain a folder and a file (parent::$path/myfolder/myfile). Then myfolder has to be created before!

Parameters

$filename

the filename, without .json

$lockex

lock the file exclusive, if yo

$otherpath

use another path than parent::$path

__destruct()

__destruct() 

Write file contents on exit, if file changed

write_content()

write_content() : \successful

Write file contents, if file writeable and changed

Returns

\successful —

written?

setValueHelper()

setValueHelper(  $index,   $value,   $data) 

Parameters

$index
$value
$data