В силу того что читать я не наживу, изучал практическими методами (ставил себе задачи и с подошью справки их реализовывал).
Но вот настал черед ООП и я ни как не могу его понять - как и с чем это "есть".
Попробовал написать класс работы с текстовой базой(код ниже), что то вроде получается, но смысл этого ООП когда все похоже на процедурное программирование?
Вообщем подскажите что я начал делать не так, потому что мне кажется что я пишу это "Филькина грамота"
вот собственно код:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- class JsonDB {
- public $txt = '.txt';
- public $confDB = '-conf.txt';
- public $error = 'Не найдена таблица с данными!';
- function SELECT($fileDB) {
- if ($this->checkfile($fileDB)){
- $dd = $this->reading($fileDB.$this->txt);
- return $dd;
- } else {
- return $this->error;
- }
- }
- function INSERT($fileDB, $param) {
- if ($this->checkfile($fileDB)){
- $data = $this->reading($fileDB.$this->txt);
- $param['id'] = ($this->ID($data))+1;
- $data[] = $param;
- $this->record($fileDB.$this->txt, $data);
- } else {
- return $this->error;
- }
- }
- function UPDATE($fileDB, $param) {
- if ($this->checkfile($fileDB)){
- } else {
- return $this->error;
- }
- }
- function DELETE($fileDB, $param) {
- if ($this->checkfile($fileDB)){
- $data = $this->reading($fileDB.$this->txt);
- foreach ($data as $k => $v) {
- foreach ($param as $key => $value) {
- if ($value == $data[$k][$key]){
- } else {
- $rec[] = $data[$k];
- }
- }
- }
- $this->record($fileDB.$this->txt, $rec);
- } else {
- return $this->error;
- }
- }
- function CREATE($fileDB){
- if (!$this->checkfile($fileDB)){
- }
- }
- function DROP($fileDB){
- if (!$this->checkfile($fileDB)){
- } else {
- return $this->error;
- }
- }
- private function record($fileDB, $data){
- //Пишем
- }
- private function reading($fileDB){
- //Читаем
- }
- private function ID($DB){
- }else {
- return 0;
- }
- return (int)$DB[$col]['id'];
- }
- private function checkfile($fileDB){
- return true;
- } else {
- return false;
- }
- }
- }
- ?>