You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use the class PreparedQueryStatement for prepared queries.
* Move methods used for prepared queries in class
PreparedQueryStatement.
* Create a .htaccess file in each created servers with user's
credentials.
* Fix bug with server's creation (server's path and user's credentials
wasn't saved)
thrownewException("JSONDB Error: Can't bind the value \"{$value}\" for the key \"{$key}\". The key isn't in the query.");
532
-
}
533
-
} else {
534
-
thrownewException("JSONDB Error: Can't use JSONDB::bindValue() with non prepared queries. Send your query with JSONDB::prepare() first.");
535
-
}
506
+
returnnewPreparedQueryStatement($query, $this);
536
507
}
537
508
538
509
/**
@@ -550,31 +521,32 @@ public static function quote($value)
550
521
* @return mixed
551
522
* @throws Exception
552
523
*/
553
-
publicfunctionexecute()
524
+
privatefunctionexecute()
554
525
{
555
-
if (NULL === $this->database || NULL === $this->parsedQuery) {
556
-
thrownewException("JSONDB Error: Can't execute the query. No database/table selected or internal error.");
557
-
}
526
+
if (!$this->queryIsExecuted()) {
527
+
if (NULL === $this->database || NULL === $this->parsedQuery) {
528
+
thrownewException("JSONDB Error: Can't execute the query. No database/table selected or internal error.");
529
+
}
558
530
559
-
if ($this->queryIsPrepared()) {
560
-
$this->queryIsPrepared = FALSE;
561
-
return$this->query($this->queryString);
562
-
}
531
+
$this->setTable($this->parsedQuery['table']);
532
+
$table_path = $this->_getTablePath();
533
+
if (!file_exists($table_path) || !is_readable($table_path) || !is_writable($table_path)) {
534
+
thrownewException("JSONDB Error: Can't execute the query. The table \"{$this->table}\" doesn't exists in database \"{$this->database}\" or file access denied.");
535
+
}
563
536
564
-
$this->setTable($this->parsedQuery['table']);
565
-
$table_path = $this->_getTablePath();
566
-
if (!file_exists($table_path) || !is_readable($table_path) || !is_writable($table_path)) {
567
-
thrownewException("JSONDB Error: Can't execute the query. The table \"{$this->table}\" doesn't exists in database \"{$this->database}\" or file access denied.");
568
-
}
537
+
$json_array = $this->cache->get($table_path);
538
+
$method = "_{$this->parsedQuery['action']}";
569
539
570
-
$json_array = $this->cache->get($table_path);
571
-
$method = "_{$this->parsedQuery['action']}";
540
+
$this->benchmark->mark('jsondb_(query)_start');
541
+
$return = $this->$method($json_array);
542
+
$this->benchmark->mark('jsondb_(query)_end');
572
543
573
-
$this->benchmark->mark('jsondb_(query)_start');
574
-
$return = $this->$method($json_array);
575
-
$this->benchmark->mark('jsondb_(query)_end');
544
+
$this->queryIsExecuted = TRUE;
576
545
577
-
return$return;
546
+
return$return;
547
+
} else {
548
+
thrownewException('JSONDB Error: There is no query to execute, or the query is already executed.');
549
+
}
578
550
}
579
551
580
552
/**
@@ -605,19 +577,6 @@ public function queryIsExecuted()
605
577
return$this->queryIsExecuted === TRUE;
606
578
}
607
579
608
-
/**
609
-
* Prepare a query.
610
-
* @return JSONDB
611
-
*/
612
-
privatefunction_prepareQuery()
613
-
{
614
-
$this->queryIsPrepared = TRUE;
615
-
$query = $this->queryString;
616
-
preg_match_all('#(:[\w]+)#', $query, $keys);
617
-
$this->preparedQueryKeys = $keys[0];
618
-
returnstatic::getInstance();
619
-
}
620
-
621
580
/**
622
581
* @param $data
623
582
* @param bool $min
@@ -798,7 +757,7 @@ protected function _select($data)
0 commit comments