summaryrefslogtreecommitdiffstats
path: root/src/Utils
diff options
context:
space:
mode:
authorDan Ungureanu <udan1107@gmail.com>2015-06-26 14:25:19 +0300
committerDan Ungureanu <udan1107@gmail.com>2015-06-26 14:25:19 +0300
commit20b6ec1a64c4ab74778a1049baba65de221835cb (patch)
treee22f0a63743fd7941c1549143aecf28c1d76e7e1 /src/Utils
parent13a0881dc9591b3fc3eb2386eb6fde0bfb194ea6 (diff)
downloadsql-parser-20b6ec1a64c4ab74778a1049baba65de221835cb.zip
sql-parser-20b6ec1a64c4ab74778a1049baba65de221835cb.tar.gz
sql-parser-20b6ec1a64c4ab74778a1049baba65de221835cb.tar.bz2
Improved documentation.
Diffstat (limited to 'src/Utils')
-rw-r--r--src/Utils/Misc.php32
-rw-r--r--src/Utils/Query.php12
-rw-r--r--src/Utils/Routine.php14
-rw-r--r--src/Utils/Table.php22
4 files changed, 52 insertions, 28 deletions
diff --git a/src/Utils/Misc.php b/src/Utils/Misc.php
index 55ae33b..85c2399 100644
--- a/src/Utils/Misc.php
+++ b/src/Utils/Misc.php
@@ -1,5 +1,11 @@
<?php
+/**
+ * Miscellaneous utilities.
+ *
+ * @package SqlParser
+ * @subpackage Utils
+ */
namespace SqlParser\Utils;
use SqlParser\Statement;
@@ -20,14 +26,14 @@ class Misc
/**
* Gets a list of all aliases and their original names.
*
- * @param SelectStatement $tree The tree that was generated after parsing.
- * @param string $database The name of the database.
+ * @param SelectStatement $statement The statement to be processed.
+ * @param string $database The name of the database.
*
* @return array
*/
- public static function getAliases($tree, $database)
+ public static function getAliases($statement, $database)
{
- if ((empty($tree->from)) || (empty($tree->expr))) {
+ if ((empty($statement->from)) || (empty($statement->expr))) {
return array();
}
@@ -35,28 +41,28 @@ class Misc
$tables = array();
- if ((!empty($tree->join->expr->table))
- && (!empty($tree->join->expr->alias))
+ if ((!empty($statement->join->expr->table))
+ && (!empty($statement->join->expr->alias))
) {
- $thisDb = empty($tree->join->expr->database) ?
- $database : $tree->join->expr->database;
+ $thisDb = empty($statement->join->expr->database) ?
+ $database : $statement->join->expr->database;
$retval = array(
$thisDb => array(
'alias' => null,
'tables' => array(
- $tree->join->expr->table => array(
- 'alias' => $tree->join->expr->alias,
+ $statement->join->expr->table => array(
+ 'alias' => $statement->join->expr->alias,
'columns' => array(),
),
),
),
);
- $tables[$thisDb][$tree->join->expr->alias] = $tree->join->expr->table;
+ $tables[$thisDb][$statement->join->expr->alias] = $statement->join->expr->table;
}
- foreach ($tree->from as $expr) {
+ foreach ($statement->from as $expr) {
if (empty($expr->table)) {
continue;
}
@@ -83,7 +89,7 @@ class Misc
$tables[$thisDb][$expr->alias] = $expr->table;
}
- foreach ($tree->expr as $expr) {
+ foreach ($statement->expr as $expr) {
if ((empty($expr->column)) || (empty($expr->alias))) {
continue;
}
diff --git a/src/Utils/Query.php b/src/Utils/Query.php
index c308344..b1a95b1 100644
--- a/src/Utils/Query.php
+++ b/src/Utils/Query.php
@@ -1,5 +1,11 @@
<?php
+/**
+ * Statement utilities.
+ *
+ * @package SqlParser
+ * @subpackage Utils
+ */
namespace SqlParser\Utils;
use SqlParser\Parser;
@@ -45,8 +51,8 @@ class Query
/**
* Gets an array with flags this statement has.
*
- * @param Statement $statement
- * @param bool $all If `false`, false values will not be included.
+ * @param Statement $statement The statement to be processed.
+ * @param bool $all If `false`, false values will not be included.
*
* @return array
*/
@@ -164,7 +170,7 @@ class Query
/**
* Parses a query and gets all information about it.
*
- * @param string $query
+ * @param string $query The query to be parsed.
*
* @return array
*/
diff --git a/src/Utils/Routine.php b/src/Utils/Routine.php
index 76d3d71..4b9b21d 100644
--- a/src/Utils/Routine.php
+++ b/src/Utils/Routine.php
@@ -1,5 +1,11 @@
<?php
+/**
+ * Routine utilities.
+ *
+ * @package SqlParser
+ * @subpackage Utils
+ */
namespace SqlParser\Utils;
use SqlParser\Lexer;
@@ -90,11 +96,11 @@ class Routine
/**
* Gets the parameters of a routine from the parse tree.
*
- * @param CreateStatement $tree The tree that was generated after parsing.
+ * @param CreateStatement $statement The statement to be processed.
*
* @return array
*/
- public static function getParameters($tree)
+ public static function getParameters($statement)
{
$retval = array(
'num' => 0,
@@ -106,9 +112,9 @@ class Routine
'opts' => array(),
);
- if (!empty($tree->parameters)) {
+ if (!empty($statement->parameters)) {
$idx = 0;
- foreach ($tree->parameters as $param) {
+ foreach ($statement->parameters as $param) {
$retval['dir'][$idx] = $param->inOut;
$retval['name'][$idx] = $param->name;
$retval['type'][$idx] = $param->type->name;
diff --git a/src/Utils/Table.php b/src/Utils/Table.php
index 6bc83a5..95b6850 100644
--- a/src/Utils/Table.php
+++ b/src/Utils/Table.php
@@ -1,5 +1,11 @@
<?php
+/**
+ * Table utilities.
+ *
+ * @package SqlParser
+ * @subpackage Utils
+ */
namespace SqlParser\Utils;
use SqlParser\Lexer;
@@ -24,19 +30,19 @@ class Table
/**
* Gets the foreign keys of the table.
*
- * @param CreateStatement $tree
+ * @param CreateStatement $statement The statement to be processed.
*
* @return array
*/
- public static function getForeignKeys($tree)
+ public static function getForeignKeys($statement)
{
- if ((empty($tree->fields)) || (!$tree->options->has('TABLE'))) {
+ if ((empty($statement->fields)) || (!$statement->options->has('TABLE'))) {
return array();
}
$ret = array();
- foreach ($tree->fields as $field) {
+ foreach ($statement->fields as $field) {
if ((empty($field->key)) || ($field->key->type !== 'FOREIGN KEY')) {
continue;
@@ -74,19 +80,19 @@ class Table
/**
* Gets fields of the table.
*
- * @param CreateStatement $tree
+ * @param CreateStatement $statement The statement to be processed.
*
* @return array
*/
- public static function getFields($tree)
+ public static function getFields($statement)
{
- if ((empty($tree->fields)) || (!$tree->options->has('TABLE'))) {
+ if ((empty($statement->fields)) || (!$statement->options->has('TABLE'))) {
return array();
}
$ret = array();
- foreach ($tree->fields as $field) {
+ foreach ($statement->fields as $field) {
// Skipping keys.
if (empty($field->type)) {