Updated code comments for PHPDocumentor - column classes

git-svn-id: http://xe-core.googlecode.com/svn/branches/luminous@12418 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2012-12-17 14:29:23 +00:00
parent 2334535831
commit 39c2f06aa7
11 changed files with 457 additions and 367 deletions

View file

@ -44,6 +44,7 @@ if(!defined('__XE_LOADED_XML_CLASS__')){
*
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml
* @version 0.1
*/
class XmlQueryParser extends XmlParser {

View file

@ -9,6 +9,7 @@
*
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery
* @version 0.1
*/
class DBParser
{

View file

@ -8,6 +8,7 @@
*
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery
* @version 0.1
*/
class QueryParser {

View file

@ -1,16 +1,17 @@
<?php
/**
/**
* ColumnTag class
* Models the <column> tag inside an XML Query file
* Since the <column> tag supports different attributes depending on
* the type of query (select, update, insert, delete) this is only
* the base class for the classes that will model each type <column> tag.
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class ColumnTag {
class ColumnTag
{
/**
* Column name
* @var string
@ -18,11 +19,12 @@
var $name;
/**
* constructor
* Constructor
* @param string $name
* @return void
*/
function ColumnTag($name){
function ColumnTag($name)
{
$this->name = $name;
}
}
}

View file

@ -1,21 +1,22 @@
<?php
/**
/**
* InsertColumnTag
* Models the <column> tag inside an XML Query file whose action is 'insert'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class InsertColumnTag extends ColumnTag {
class InsertColumnTag extends ColumnTag
{
/**
* argument
* Argument
* @var QueryArgument object
*/
var $argument;
/**
* constructor
* Constructor
* @param object $column
* @return void
*/
@ -26,15 +27,27 @@
$this->argument = new QueryArgument($column);
}
/**
* Returns the string to be output in the cache file
* used for instantiating an InsertExpression when a
* query is executed
*
* @return string
*/
function getExpressionString(){
return sprintf('new InsertExpression(\'%s\', ${\'%s_argument\'})'
, $this->name
, $this->argument->argument_name);
}
/**
* Returns the QueryArgument object associated with this INSERT statement
*
* @return QueryArgument
*/
function getArgument(){
return $this->argument;
}
}
}
?>

View file

@ -1,31 +1,46 @@
<?php
/**
/**
* InsertColumnTagWithoutArgument
* Models the <column> tag inside an XML Query file whose action is 'insert-select'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class InsertColumnTagWithoutArgument extends ColumnTag {
class InsertColumnTagWithoutArgument extends ColumnTag
{
/**
* constructor
* Constructor
*
* @param object $column
* @return void
*/
function InsertColumnTagWithoutArgument($column) {
function InsertColumnTagWithoutArgument($column)
{
parent::ColumnTag($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);
}
function getExpressionString(){
/**
* Returns the string to be output in the cache file
*
* @return string
*/
function getExpressionString()
{
return sprintf('new Expression(\'%s\')', $this->name);
}
function getArgument(){
return null;
/**
* Returns the QueryArgument object associated with this INSERT statement
*
* @return null
*/
function getArgument()
{
return NULL;
}
}
}
?>

View file

@ -1,13 +1,13 @@
<?php
/**
/**
* InsertColumnsTag class
* Models the <column> tag inside an XML Query file whose action is 'insert'
* Models the <columns> tag inside an XML Query file whose action is 'insert'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class InsertColumnsTag{
class InsertColumnsTag{
/**
* Column list
* @var array value is InsertColumnTag object
@ -15,11 +15,12 @@
var $columns;
/**
* constructor
* Constructor
* @param array|string $xml_columns
* @return void
*/
function InsertColumnsTag($xml_columns) {
function InsertColumnsTag($xml_columns)
{
$this->columns = array();
if(!$xml_columns)
@ -38,7 +39,8 @@
* InsertColumnTag object to string
* @return string
*/
function toString(){
function toString()
{
$output_columns = 'array(' . PHP_EOL;
foreach($this->columns as $column){
$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
@ -52,7 +54,8 @@
* Return argument list
* @return array
*/
function getArguments(){
function getArguments()
{
$arguments = array();
foreach($this->columns as $column){
$arguments[] = $column->getArgument();
@ -60,6 +63,6 @@
return $arguments;
}
}
}
?>

View file

@ -1,30 +1,33 @@
<?php
/**
/**
* SelectColumnTag
* Models the <column> tag inside an XML Query file whose action is 'select'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class SelectColumnTag extends ColumnTag{
class SelectColumnTag extends ColumnTag
{
/**
* alias
* Column alias
* @var string
*/
var $alias;
/**
* click count status
* Click count status
* @var bool
*/
var $click_count;
/**
* constructor
* Constructor
* @param string|object $column
* @return void
*/
function SelectColumnTag($column){
function SelectColumnTag($column)
{
if ($column == "*" || $column->attrs->name == '*')
{
parent::ColumnTag(NULL);
@ -41,6 +44,16 @@
}
}
/**
* Returns the string to be output in the cache file
*
* A select column tag in an XML query can be used for:
* - a star expression: SELECT *
* - a click count expression: SELECT + UPDATE
* - any other select expression (column name, function call etc).
*
* @return string
*/
function getExpressionString(){
if($this->name == '*') return "new StarExpression()";
if($this->click_count)
@ -50,4 +63,4 @@
$dbParser = DB::getParser();
return sprintf('new SelectExpression(\'%s\'%s)', $this->name, $this->alias ? ', \''.$dbParser->escape($this->alias) .'\'': '');
}
}
}

View file

@ -1,12 +1,14 @@
<?php
/**
* SelectColumnTag class
/**
* SelectColumnsTag class
* Models the <columns> tag inside an XML Query file whose action is 'select'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class SelectColumnsTag {
class SelectColumnsTag
{
/**
* Column list
* @var array value is SelectColumnTag object
@ -14,11 +16,14 @@
var $columns;
/**
* constructor
* @param Xml_Node_ $xml_columns
* Constructor
*
* @param $xml_columns_tag
* @internal param \Xml_Node_ $xml_columns
* @return void
*/
function SelectColumnsTag($xml_columns_tag){
function SelectColumnsTag($xml_columns_tag)
{
if (!$xml_columns_tag)
$xml_columns_tag = new Xml_Node_();
@ -46,15 +51,17 @@
if(!is_array($xml_queries)) $xml_queries = array($xml_queries);
foreach($xml_queries as $column){
$this->columns[] = new QueryTag($column, true);
$this->columns[] = new QueryTag($column, TRUE);
}
}
/**
* SelectColumnTag object to string
* Returns the string to be output in the cache file
*
* @return string
*/
function toString(){
function toString()
{
$output_columns = 'array(' . PHP_EOL;
foreach($this->columns as $column){
if(is_a($column, 'QueryTag'))
@ -69,9 +76,11 @@
/**
* Return argument list
*
* @return array
*/
function getArguments(){
function getArguments()
{
$arguments = array();
foreach($this->columns as $column){
if(is_a($column, 'QueryTag'))
@ -79,5 +88,5 @@
}
return $arguments;
}
}
}
?>

View file

@ -1,49 +1,61 @@
<?php
/**
/**
* UpdateColumnTag
* Models the <column> tag inside an XML Query file whose action is 'update'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class UpdateColumnTag extends ColumnTag {
class UpdateColumnTag extends ColumnTag {
/**
* argument
* Argument
* @var QueryArgument object
*/
var $argument;
/**
* default value
* Default value
* @var string
*/
var $default_value;
/**
* constructor
* Constructor
* @param object $column
* @return void
*/
function UpdateColumnTag($column) {
function UpdateColumnTag($column)
{
parent::ColumnTag($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);
if($column->attrs->var)
$this->argument = new QueryArgument($column);
else {
if(strpos($column->attrs->default, '.') !== false)
if(strpos($column->attrs->default, '.') !== FALSE)
{
$this->default_value = "'" . $dbParser->parseColumnName($column->attrs->default) . "'";
else {
}
else
{
$default_value = new DefaultValue($this->name, $column->attrs->default);
if($default_value->isOperation())
$this->argument = new QueryArgument($column, true);
{
$this->argument = new QueryArgument($column, TRUE);
}
//else $this->default_value = $dbParser->parseColumnName($column->attrs->default);
else {
else
{
$this->default_value = $default_value->toString();
if($default_value->isStringFromFunction()){
if($default_value->isStringFromFunction())
{
$this->default_value = '"\'".' . $this->default_value . '."\'"';
}
if($default_value->isString()){
if($default_value->isString())
{
$this->default_value = '"' . $this->default_value . '"';
}
}
@ -53,21 +65,36 @@
}
}
function getExpressionString(){
/**
* Returns the string to be output in the cache file
*
* @return string
*/
function getExpressionString()
{
if($this->argument)
{
return sprintf('new UpdateExpression(\'%s\', ${\'%s_argument\'})'
, $this->name
, $this->argument->argument_name);
else {
}
else
{
return sprintf('new UpdateExpressionWithoutArgument(\'%s\', %s)'
, $this->name
, $this->default_value);
}
}
function getArgument(){
/**
* Returns the Argument associated with this update statement
*
* @return QueryArgument
*/
function getArgument()
{
return $this->argument;
}
}
}
?>

View file

@ -1,13 +1,13 @@
<?php
/**
/**
* UpdateColumnsTag
* Models the <column> tag inside an XML Query file whose action is 'update'
* Models the <columns> tag inside an XML Query file whose action is 'update'
*
* @author Arnia Software
* @author Corina Udrescu (corina.udrescu@arnia.ro)
* @package /classes/xml/xmlquery/tags/column
* @version 0.1
*/
class UpdateColumnsTag{
class UpdateColumnsTag{
/**
* Column list
* @var array value is UpdateColumnTag object
@ -15,11 +15,12 @@
var $columns;
/**
* constructor
* @param array|string $xml_columns
* Constructor
* @param array|object $xml_columns
* @return void
*/
function UpdateColumnsTag($xml_columns) {
function UpdateColumnsTag($xml_columns)
{
$this->columns = array();
if(!is_array($xml_columns)) $xml_columns = array($xml_columns);
@ -31,10 +32,12 @@
}
/**
* UpdateColumnTag object to string
* Returns the string to be output in the cache file
*
* @return string
*/
function toString(){
function toString()
{
$output_columns = 'array(' . PHP_EOL;
foreach($this->columns as $column){
$output_columns .= $column->getExpressionString() . PHP_EOL . ',';
@ -46,9 +49,11 @@
/**
* Return argument list
*
* @return array
*/
function getArguments(){
function getArguments()
{
$arguments = array();
foreach($this->columns as $column){
$arguments[] = $column->getArgument();
@ -56,6 +61,6 @@
return $arguments;
}
}
}
?>