XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
TableTag.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
23 class TableTag
24 {
25 
31 
36  var $name;
37 
42  var $alias;
43 
50 
56 
62 
69  function __construct($table)
70  {
71  $dbParser = DB::getParser();
72 
73  $this->unescaped_name = $table->attrs->name;
74  $this->name = $dbParser->parseTableName($table->attrs->name);
75 
76  $this->alias = $table->attrs->alias;
77  if(!$this->alias)
78  {
79  $this->alias = $table->attrs->name;
80  }
81 
82  $this->join_type = $table->attrs->type;
83 
84  $this->conditions = $table->conditions;
85 
86  if($this->isJoinTable())
87  {
88  $this->conditionsTag = new JoinConditionsTag($this->conditions);
89  }
90  }
91 
92  function isJoinTable()
93  {
94  $joinList = array('left join' => 1, 'left outer join' => 1, 'right join' => 1, 'right outer join' => 1);
95  if(isset($joinList[$this->join_type]) && count($this->conditions))
96  {
97  return true;
98  }
99  return false;
100  }
101 
102  function getTableAlias()
103  {
104  return $this->alias;
105  }
106 
107  function getTableName()
108  {
109  return $this->unescaped_name;
110  }
111 
118  function getTableString()
119  {
120  $dbParser = DB::getParser();
121 
122  if($this->isJoinTable())
123  {
124  return sprintf('new JoinTable(\'%s\', \'%s\', "%s", %s)'
125  , $dbParser->escape($this->name)
126  , $dbParser->escape($this->alias)
127  , $this->join_type, $this->conditionsTag->toString());
128  }
129  return sprintf('new Table(\'%s\'%s)'
130  , $dbParser->escape($this->name)
131  , $this->alias ? ', \'' . $dbParser->escape($this->alias) . '\'' : '');
132  }
133 
134  function getArguments()
135  {
136  if(!isset($this->conditionsTag))
137  {
138  return array();
139  }
140  return $this->conditionsTag->getArguments();
141  }
142 
143 }
144 /* End of file TableTag.class.php */
145 /* Location: ./classes/xml/xmlquery/tags/table/TableTag.class.php */
getParser($force=FALSE)
Definition: DB.class.php:1345
__construct($table)