Coder Social home page Coder Social logo

crunchdb's People

Contributors

cybrox avatar zshare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kafkaforks

crunchdb's Issues

For some reason the DB has died.

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

count(): Parameter must be an array or an object that implements Countable

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

The operation delete not working ($inp['__dbid'] order mismatch)

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.