modifs.mineures sans commentaires
This commit is contained in:
		
							parent
							
								
									a3ae6847d4
								
							
						
					
					
						commit
						c1ce91ec81
					
				@ -3,6 +3,7 @@ namespace nur\sery\db\sqlite;
 | 
			
		||||
 | 
			
		||||
use nur\sery\cl;
 | 
			
		||||
use nur\sery\php\func;
 | 
			
		||||
use nur\sery\ValueException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class SqliteCapacitor: objet permettant d'accumuler des données pour les
 | 
			
		||||
@ -22,13 +23,14 @@ class SqliteCapacitor {
 | 
			
		||||
 | 
			
		||||
  /** tester si le canal spécifié existe */
 | 
			
		||||
  function exists(?string $channel=null): bool {
 | 
			
		||||
 | 
			
		||||
    #XXX maintenir une table channels avec la liste des canaux valides
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** supprimer le canal spécifié */
 | 
			
		||||
  function reset(?string $channel=null) {
 | 
			
		||||
    $tableName = $this->getTableName($channel);
 | 
			
		||||
    $this->sqlite->exec("drop table if exists $tableName");
 | 
			
		||||
    #XXX maj de la tables channels
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** @var array */
 | 
			
		||||
@ -66,14 +68,15 @@ class SqliteCapacitor {
 | 
			
		||||
    ]);
 | 
			
		||||
    #XXX^^^ migrer vers la syntaxe tableau de create
 | 
			
		||||
    $this->sqlite->exec($query);
 | 
			
		||||
    #XXX maj de la tables channels
 | 
			
		||||
    $this->created[$channel] = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function charge($item, ?string $channel=null) {
 | 
			
		||||
    $this->create($channel);
 | 
			
		||||
    $values = cl::merge([
 | 
			
		||||
    $values = cl::merge($this->getKeyValues($item, $channel), [
 | 
			
		||||
      "_item" => serialize($item),
 | 
			
		||||
    ], $this->getKeyValues($item, $channel));
 | 
			
		||||
    ]);
 | 
			
		||||
    $this->sqlite->exec([
 | 
			
		||||
      "insert",
 | 
			
		||||
      "into" => $this->getTableName($channel),
 | 
			
		||||
@ -94,17 +97,31 @@ class SqliteCapacitor {
 | 
			
		||||
    if ($reset) $this->reset($channel);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** appeler une fonction pour chaque élément du canal spécifié */
 | 
			
		||||
  function each(callable $func, ?string $channel=null): void {
 | 
			
		||||
  /**
 | 
			
		||||
   * appeler une fonction pour chaque élément du canal spécifié.
 | 
			
		||||
   *
 | 
			
		||||
   * $keys permet de filtrer parmi les élements chargés
 | 
			
		||||
   *
 | 
			
		||||
   * si $func retourne un tableau, il est utilisé pour mettre à jour
 | 
			
		||||
   * l'enregistrement.
 | 
			
		||||
   */
 | 
			
		||||
  function each(callable $func, ?array $keys, ?string $channel=null): void {
 | 
			
		||||
    $context = func::_prepare($func);
 | 
			
		||||
    foreach ($this->discharge($channel, false) as $item) {
 | 
			
		||||
      func::_call($context, [$item]);
 | 
			
		||||
      $result = func::_call($context, [$item]);
 | 
			
		||||
      #XXX
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /** obtenir l'élément identifié par les clés spécifiées sur le canal spécifié */
 | 
			
		||||
  function get(?array $keys, ?string $channel=null) {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * obtenir l'élément identifié par les clés spécifiées sur le canal spécifié
 | 
			
		||||
   *
 | 
			
		||||
   * si $keys n'est pas un tableau, il est transformé en ["_id" => $keys]
 | 
			
		||||
   */
 | 
			
		||||
  function get($keys, ?string $channel=null) {
 | 
			
		||||
    if ($keys === null) throw ValueException::null("keys");
 | 
			
		||||
    if (!is_array($keys)) $keys = ["_id" => $keys];
 | 
			
		||||
    #XXX
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function close(): void {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user