Last active
August 29, 2015 14:00
-
-
Save lostphilosopher/a0160e687d0926d3b0c8 to your computer and use it in GitHub Desktop.
nodb prototype with files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* This class exists as a placeholder for a database it should | |
* suffice for prototyping purposes, but shoud NOT be used in | |
* production | |
*/ | |
class NoDb { | |
protected $noDbFile = ''; | |
// Contstructor | |
public function __construct($noDbFile = null) { | |
$parentDir = dirname(dirname(__FILE__)); | |
$this->noDbFile = 'public/noDb/storage.txt'; | |
} | |
// | |
public function post($preJson) { | |
$json = json_encode($preJson); | |
$file = fopen($this->noDbFile, 'w'); | |
fwrite($file, $json); | |
fclose($file); | |
} | |
// | |
public function get() { | |
$json = file_get_contents($this->noDbFile); | |
$jsonArray = json_decode($json,true); | |
$result = $jsonArray; | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment