PHP code example of auzadventure / yii2-jsondb

1. Go to this page and download the library: Download auzadventure/yii2-jsondb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

auzadventure / yii2-jsondb example snippets


php composer.phar 
 $jsonDB->insert($array) 

 

namespace app\models;

use Yii;
use yii\base\Model;
use auzadventure\jsondb\JsonDB;
use yii\helpers\Url;


class Ads extends Model {
	
	public $title;
	public $url;
	public $blurp;
	
	public $filepath;
	public $jsondb; 
	public $id; 
	
	public function rules()
    {
        return [
            // name, email, subject and body are >jsondb->findAll()->data;
	}
	
	public function save() {
		
		$file = self::getFilePath();
		
		$jsondb = new JsonDB($file);
		$jsondb->insert(['title'=>$this->title,
						 'url'=>$this->url,
						 'blurp'=>$this->blurp
						]);
			
	}
	
	public function delete($id) {
		return $this->jsondb->deleteByID($id);
	}

}