Changeset 82602 in spip-zone
- Timestamp:
- May 19, 2014, 10:00:20 PM (7 years ago)
- Location:
- _plugins_/indexer/trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/indexer/trunk/lib/Indexer/Storage/Sphinx.php
r82568 r82602 26 26 (id, title, summary, content, date, uri, properties, signature) 27 27 VALUES 28 (:id, :title, :summary, :content, :date, :uri, :properties, :signature)29 28 "; 30 $prepare = $this->sphinxql->prepare($query);31 29 30 // insertion document par document 31 // il semble que sphinxql n'aime pas plusieurs lignes d'un coup. 32 32 foreach ($documents as $document) { 33 33 $data = $this->reformatDocument($document); 34 if (!$prepare->execute($data)){ 35 echo "<pre>".print_r($prepare->errorInfo(), true)."</pre>"; 34 $data = array_map(array($this->sphinxql, 'escape_string'), $data); 35 $q = $query . "('" . implode("', '", $data) . "')"; 36 if (!$this->sphinxql->query($q)) { 37 echo "<pre>".print_r($this->sphinxql->errors(), true)."</pre>"; 38 echo "<pre>".print_r($q, true)."</pre>"; 36 39 exit; 37 } 40 } 38 41 } 42 43 // par lot de 10 entrées 44 /* 45 $sep = $values = ''; 46 $n = 0; 47 foreach ($documents as $document) { 48 $data = $this->reformatDocument($document); 49 $data = array_map(array($this->sphinxql, 'escape_string'), $data); 50 $values .= $sep . " ('" . implode("', '", $data) . "')"; 51 $sep = ','; 52 if (++$n == 10) { 53 if (!$this->sphinxql->query($query . $values)) { 54 echo "<pre>".print_r($this->sphinxql->errors(), true)."</pre>"; 55 exit; 56 } 57 $n = 0; 58 $sep = $values = ''; 59 }; 60 } 61 62 if ($n and !$this->sphinxql->query($query . $values)) { 63 echo "<pre>".print_r($this->sphinxql->errors(), true)."</pre>"; 64 exit; 65 }*/ 39 66 } 40 67 -
_plugins_/indexer/trunk/lib/Sphinx/SphinxQL/SphinxQL.php
r82594 r82602 40 40 } 41 41 42 42 43 /** 43 * Prépare une requête44 * Échappe une chaîne 44 45 **/ 45 public function prepare($query) {46 public function escape_string($string) { 46 47 if (!$this->sql) { 47 48 return false; 48 49 } 49 return $this->sql->prepare($query); 50 return $this->sql->escape_string($string); 51 } 52 53 /** 54 * Récupère les dernières erreurs 55 **/ 56 public function errors() { 57 if (!$this->sql) { 58 return false; 59 } 60 return $this->sql->error_list; 50 61 } 51 62
Note: See TracChangeset
for help on using the changeset viewer.