From 766b5a7011e8b174f2bee7c43c501600b8991058 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 14 Sep 2017 16:20:18 +0200 Subject: [PATCH] No more lightdb:delete v11 --- build/lightdb/core/lightdb.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/build/lightdb/core/lightdb.php b/build/lightdb/core/lightdb.php index eb9f1fe..eeec1c5 100644 --- a/build/lightdb/core/lightdb.php +++ b/build/lightdb/core/lightdb.php @@ -122,19 +122,16 @@ * */ public function insert($key, $data){ - $already_line = $this->line; - /* (1) On vérifie que la clé est unique */ if( array_key_exists($key, $this->index) ) - $already_line = $this->index[$key]['line']; + return false; $key = (string) $key; /* (2) On ajoute les données aux fichier */ $json_data = json_encode($data); - $this->driver->seek($already_line); - if( $already_line == $this->line ) - $this->line++; + $this->driver->seek($this->line); + $this->line++; $written = $this->driver->fwrite( $json_data.PHP_EOL ); // Si erreur d'écriture, on retourne FALSE @@ -143,7 +140,7 @@ /* (3) On enregistre l'index */ $this->index[$key] = [ - 'line' => $already_line - 1, + 'line' => $this->line - 1, 'hash' => sha1($json_data) ];