Changeset 82584 in spip-zone
- Timestamp:
- May 19, 2014, 5:16:58 PM (7 years ago)
- Location:
- _plugins_/indexer/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/indexer/trunk/indexer_fonctions.php
r82575 r82584 110 110 111 111 if ($orderby) { 112 // permettre un order by (formule compliquee AS tseg) dans la boucle DATA 113 if (preg_match(',^(.*) AS (\w+),i', $orderby, $r)) { 114 $sq->select($r[0]); 115 $orderby = str_replace($r[0], $r[2], $orderby); 116 } 112 117 $sq->orderby($orderby); 113 118 } -
_plugins_/indexer/trunk/lib/Sphinx/SphinxQL/SphinxQL.php
r82579 r82584 9 9 private $host; 10 10 private $port; 11 private $sql; // objet PDO11 private $sql; // objet MySQLi 12 12 13 13 public function __construct($host = '127.0.0.1', $port = 9306) { … … 22 22 public function connect() { 23 23 try { 24 $this->sql = new \ PDO("mysql:host=" . $this->host . ";port=" . $this->port, "", "");24 $this->sql = new \MySQLi($this->host, null, null, null, $this->port); 25 25 } catch (\Exception $e) { 26 26 var_dump($e->getMessage()); … … 37 37 return false; 38 38 } 39 return $this->sql-> query($query);39 return $this->sql->multi_query($query); 40 40 } 41 41 … … 66 66 ); 67 67 68 if ($docs = $this->query($query)) { 69 // les jeux de réponses sont les suivant : 68 try { 69 $docs = $this->query($query); 70 71 // les jeux de réponses sont les suivants : 70 72 // 1) les documents trouvés 71 73 // 2+) les FACET à la suite 72 74 $reponses = array(); 73 do { 74 $reponses[] = $docs->fetchAll(\PDO::FETCH_ASSOC); 75 } while ($docs->nextRowset()); 75 do { 76 if ($result = $this->sql->store_result()) { 77 $reponses[] = $result->fetch_all(MYSQLI_ASSOC); 78 $result->free(); 79 } 80 } while ($this->sql->next_result()); 76 81 77 82 $liste['docs'] = array_shift($reponses); 78 83 $liste['facets'] = $this->parseFacets($reponses); 79 84 80 $meta = $this->query('SHOW meta'); 81 if ($errs = $this->sql->errorInfo()) { 82 # TODO: comprendre le pourquoi de l'erreur 83 # Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. 84 var_dump($errs); 85 } 86 if ($meta) { 87 $liste['meta'] = $this->parseMeta($meta->fetchAll(\PDO::FETCH_ASSOC)); 88 } 89 } elseif ($errs = $this->sql->errorInfo()) { 90 var_dump($errs); 85 } catch (\Exception $e) { 86 echo "\n<div><tt>",htmlspecialchars($query),"</tt></div>\n"; 87 var_dump($e->getMessage()); 88 return false; 89 } 90 91 // recuperer les META 92 if ($meta = $this->query('SHOW META')) { 93 $result = $this->sql->store_result(); 94 $liste['meta'] = $this->parseMeta($result->fetch_all(MYSQLI_ASSOC)); 91 95 } 92 96 -
_plugins_/indexer/trunk/prive/squelettes/contenu/indexer.html
r82568 r82584 12 12 new Sphinx\SphinxQL\SphinxQL(SPHINX_SERVER_HOST, SPHINX_SERVER_PORT), SPHINX_DEFAULT_INDEX) 13 13 ); 14 } catch( PDOException $e ) {14 } catch( \Exception $e ) { 15 15 if (!$message = $e->getMessage()) 16 16 $message = _L('Erreur inconnue');
Note: See TracChangeset
for help on using the changeset viewer.