cybrox / crunchdb Goto Github PK
View Code? Open in Web Editor NEWA simple JSON based database system written in PHP. Useful for smaller applications.
License: MIT License
A simple JSON based database system written in PHP. Useful for smaller applications.
License: MIT License
Hi,
The database worked fine for few months and suddenly i got call that things are not working.. S o 3 days of user submissions gone. The DB was totally reseted to empty, we were able to recover data from 3 days ago.
[29-Jul-2018 06:19:06 Europe/Bratislava] PHP Warning: array_push() expects parameter 1 to be array, null given in /public_html/vendor/cybrox/crunchdb/src/crunchTable.php on line 141
[29-Jul-2018 07:00:43 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 43
[29-Jul-2018 07:00:43 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 143
[29-Jul-2018 07:05:44 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 43
[29-Jul-2018 07:05:44 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 143
[29-Jul-2018 07:21:19 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 43
[29-Jul-2018 07:21:19 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 143
[29-Jul-2018 07:21:29 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 43
[29-Jul-2018 07:21:29 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 143
[29-Jul-2018 07:22:03 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 43
[29-Jul-2018 07:22:03 Europe/Bratislava] PHP Warning: Invalid argument supplied for foreach() in /public_html/vendor/cybrox/crunchdb/src/crunchResource.php on line 143
And also a array_push() expects parameter 1 to be array, null given in /vendor/cybrox/crunchdb/src/crunchTable.php on line 141
Hi there
We noticed a warning while using ->select('*')->fetch()
.
<b>Warning</b>: count(): Parameter must be an array or an object that implements Countable in <b>/.../vendor/cybrox/crunchdb/src/crunchResource.php</b> on line <b>59</b><br />ls
The warning appears because private function apply($queries){
expects $queries
to be an array.
/**
* Apply the given query to the dataset
* @param string $queries The given query
*/
private function apply($queries){
foreach($queries as $query){
if(count($query) < 3) continue;
$key = (!empty($query[0])) ? $query[0] : '';
$con = (!empty($query[3])) ? $query[3] : 'or';
if($key == '*') return;
if($con == 'or') $this->check($this->rawd, $query);
else $this->check($this->data, $query);
}
}
We found two solutions to fix that warning.
1.) If you put *
in brackets ->select(['*'])->fetch()
it behaves correctly ( returns all data ) without generating a warning.
2.) The other solution requires small improvements in the method apply
to support '*'
as a string. Here is one approach ( not tested ) which could allow $queries
to be a string.
/**
* Apply the given query to the dataset
* @param string $queries The given query
*/
private function apply($queries){
if (!is_array($queries)) {
if($queries == '*') return;
}
Cheers
Would be great, if you could add your project to the packagist repository.
https://packagist.org/
Thanks!
I experienced an issue after deleting a few records, inserting a few and again tried to delete
nothing happened...
inspected through the code
private function tweak($input){
$counter = 0;
foreach($input as $inp){
array_push($this->uids, $counter);
$inp['__dbid'] = $counter;
$this->data[] = $inp;
$counter++;
}
$this->rawd = $this->data;
}
The delete operation is based on ['__dbid'] which is based on $counter created in tweak function
So I temporarily reordered using array_values in delete function (like below)
public function delete(){
$this->base->tbdata['data'] = array_values($this->base->tbdata['data']);
foreach($this->data as $d) {
unset($this->base->tbdata['data'][$d['__dbid']]);
}
$this->base->tbdata['data'] = array_values($this->base->tbdata['data']);
$this->base->_saveData();
return true;
}
kindly look through this when you go through crunchdb
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.