Пример #1
0
 function toString()
 {
     if ($this->page) {
         return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
     } else {
         return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName());
     }
 }
Пример #2
0
 /**
  * constructor
  * @param object $condition
  * @return void
  */
 function __construct($condition)
 {
     $this->operation = $condition->attrs->operation;
     $this->pipe = $condition->attrs->pipe;
     $dbParser = DB::getParser();
     $this->column_name = $dbParser->parseExpression($condition->attrs->column);
     // If default value is column name, it should be escaped
     if ($isColumnName = strpos($condition->attrs->default, '.') !== FALSE && strpos($condition->attrs->default, '.') !== 0 && strpos($condition->attrs->default, '%') === FALSE) {
         $condition->attrs->default = $dbParser->parseExpression($condition->attrs->default);
     }
     if ($condition->node_name == 'query') {
         $this->query = new QueryTag($condition, TRUE);
         $this->default_column = $this->query->toString();
     } else {
         if ($condition->attrs->var && !strpos($condition->attrs->var, '.')) {
             $this->argument = new QueryArgument($condition);
             $this->argument_name = $this->argument->getArgumentName();
         } else {
             if (isset($condition->attrs->default)) {
                 $operationList = array('in' => 1, 'between' => 1, 'notin' => 1, 'not_in' => 1);
                 if (isset($operationList[$this->operation])) {
                     $default_value = $condition->attrs->default;
                     if (strpos($default_value, "'") !== FALSE) {
                         $default_value = "\"" . $default_value . "\"";
                     } else {
                         $default_value = "'" . $default_value . "'";
                     }
                 } else {
                     $default_value_object = new DefaultValue($this->column_name, $condition->attrs->default);
                     $default_value = $default_value_object->toString();
                     if ($default_value_object->isStringFromFunction()) {
                         $default_value = '"\'".' . $default_value . '."\'"';
                     }
                     if ($default_value_object->isString() && !$isColumnName && !is_numeric($condition->attrs->default)) {
                         if (strpos($default_value, "'") !== FALSE) {
                             $default_value = "\"" . $default_value . "\"";
                         } else {
                             $default_value = "'" . $default_value . "'";
                         }
                     }
                 }
                 $this->default_column = $default_value;
             } else {
                 $this->default_column = "'" . $dbParser->parseColumnName($condition->attrs->var) . "'";
             }
         }
     }
 }
Пример #3
0
 function toString()
 {
     return sprintf('new OrderByColumn(${\'%s_argument\'}, %s)', $this->argument->getArgumentName(), $this->sort_order);
 }