PluginProbe
SQLite Database Integration / 2.2.2
SQLite Database Integration v2.2.2
3.0.2 3.0.1 trunk 2.1.13 2.1.14 2.1.15 2.1.16 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.2.2 2.2.20 2.2.21 2.2.22 2.2.23 2.2.3 All 32 releases
sqlite-database-integration / wp-includes / mysql / class-wp-mysql-parser.php

class-wp-mysql-parser.php in SQLite Database Integration 2.2.2, at wp-includes/mysql/class-wp-mysql-parser.php

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WP_MySQL_Parser extends WP_Parser {
4 /**
5 * The current query AST.
6 *
7 * @var WP_Parser_Node|null
8 */
9 private $current_ast;
10
11 /**
12 * Parse the next query from the input SQL string.
13 *
14 * This method reads tokens until a query is parsed, or the parsing fails.
15 * It returns a boolean indicating whether a query was successfully parsed.
16 *
17 * Example:
18 *
19 * // Parse all queries in the input SQL string.
20 * $parser = new WP_MySQL_Parser( $sql );
21 * while ( $parser->next_query() ) {
22 * $ast = $parser->get_query_ast();
23 * if ( ! $ast ) {
24 * // The parsing failed.
25 * }
26 * // The query was successfully parsed.
27 * }
28 *
29 * @return bool Whether a query was successfully parsed.
30 */
31 public function next_query(): bool {
32 if ( $this->position >= count( $this->tokens ) ) {
33 return false;
34 }
35 $this->current_ast = $this->parse();
36 return true;
37 }
38
39 /**
40 * Get the current query AST.
41 *
42 * When no query has been parsed yet, the parsing failed, or the end of the
43 * input was reached, this method returns null.
44 *
45 * @see WP_MySQL_Parser::next_query() for usage example.
46 *
47 * @return WP_Parser_Node|null The current query AST, or null if no query was parsed.
48 */
49 public function get_query_ast(): ?WP_Parser_Node {
50 return $this->current_ast;
51 }
52 }
53