This commit is contained in:
Билай Станислав 2024-07-01 15:55:14 +03:00
parent b8c98693f8
commit 62bb16f581
3 changed files with 4 additions and 23 deletions

View File

@ -10,9 +10,6 @@ require_once "vendor/autoload.php";
ini_set("display_errors", true);
error_reporting(-1);
//$fileName = "Information.txt";
//$fileModeOpen = "a";
$post = new PostModel();
$post->load($_REQUEST);
$post->save();

View File

@ -1,4 +1,6 @@
autoincrement=id;last_id=2;table_name=post
autoincrement=id;last_id=4;table_name=post
id;author;post
1;Stas;Hello, world!!!
2;Stas;Hello, world!!!
3;Stas;Hello,<br>My php<br>World!!!
4;Stas;Hello,<br>My php<br>World!!!

View File

@ -151,24 +151,6 @@ class FileDatabaseDriver
fclose($this->file);
}
// public function updateServiceInfo(string $string): void
// {
// $id = $this->serviceInfo['last_id'];
// $this->serviceInfo['last_id'] = ++$id;
// foreach ($this->serviceInfo as $key => $value) {
// $arr[] = $key . '=' . $value;
// }
// $fileArr = file($this->filePath);
// if (isset($arr)) {
// $serviceStr = implode(';', $arr) . "\n";
// }
// $fileArr[0] = $serviceStr;
// file_put_contents($this->filePath, $fileArr);
//
// $str = $id . ';' . $string;
// $this->save($str);
// }
public function save(string $string): void
{
$this->serviceInfo['last_id']++;
@ -182,7 +164,7 @@ class FileDatabaseDriver
$fileArr[0] = $serviceStr;
file_put_contents($this->filePath, $fileArr);
$str = $this->serviceInfo['last_id'] . ';' . $string . "\n";
$str = $this->serviceInfo['last_id'] . ';' . str_replace("\r\n", "<br>", $string) . "\n";
fwrite($this->file, $str);
$this->close();