PHP code example of muhammetsafak / jsonbase
1. Go to this page and download the library: Download muhammetsafak/jsonbase 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/ */
muhammetsafak / jsonbase example snippets
$jsonbase_dir = __DIR__ . '/data/';
$jsonbase = new \JSONBase\Base($jsonbase_dir);
$jsonbase->create_table("table_name");
public function create_table(string $name): bool
$data = array("col_name" => "Value", "column" => "columnsValue");
$jsonbase->insert("table_name", $data);
public function insert(string $from, array $data): bool
$data = array(
array("col_name" => "Value", "column" => "columnsValue"),
array("col_name" => "Value2", "column" => "columnsValue2")
);
$jsonbase->multiInsert("table_name", $data);
public function multiInsert(string $from, array $data): bool
$data = ["column" => "newValue", "col" => "colNewValue"];
$where = ["columnName" => "colValue"];
$jsonbase->update("table_name", $where, $data);
public function update(string $from, array $where, array $data = []): bool
$where = ["id" => "340"];
$jsonbase->delete("table_name", $where);
public function delete(string $from, array $where): bool
public function drop(string $from): bool
$jsonbase->drop("table_name");
public function truncate(string $from): bool
$jsonbase->truncate("table_name");
public function rename(string $from, string $rename): bool
$jsonbase->rename("old_table_name", "new_table_name");
public function copy(string $from, string $copyName): bool
$jsonbase->copy("table_name", "table_name_copy");
public function download(string $from): void
$jsonbase->download("table_name");
public function tables(): array
foreach($jsonbase->tables() as $table_name){
echo $table_name;
}
public function size(string $from): int
foreach($jsonbase->tables() as $table_name){
echo $table_name . " : " . $jsonbase->size($table_name) . ' Byte';
}
public function rowSize(string $from): int
foreach($jsonbase->tables() as $table_name){
echo $table_name . " : " . $jsonbase->rowSize($table_name) . ' rows';
}
public function select(string $select = '*'): self
public function from(string $from): self
public function where(string $key, string $value): self
public function get(): self
public function row(): array|false
public function rows(): array|false
public function num_rows(): int
$jsonbase->select('name')->from('students')->where('id', '885')->get();
$size = $jsonbase->num_rows();
if($size > 0){
$row = $jsonbase->row();
echo $row['name'];
}else{
echo 'Result not found!';
}
$jsonbase->select('id, name')->from('students')->where('sex', 'male')->get();
$size = $jsonbase->num_rows();
if($size > 0){
foreach($jsonbase->rows() as $row){
echo $row['id'] . " - " . $row['name'] . "\n";
}
}else{
echo 'Result not found!';
}
$jsonbase->select('id, name')->from('students')->where('sex', 'famale')->where('age', '17')->get();
$size = $jsonbase->num_rows();
if($size > 0){
foreach($jsonbase->rows() as $row){
echo $row['id'] . " - " . $row['name'] . "\n";
}
}else{
echo 'Result not found!';
}