예제 #1
0
 /**
  * Get class body
  * @return Bond\Format
  */
 private function getClassBody()
 {
     // sort the class components by their name
     $this->classComponents->sort(function (PhpClassComponent $a, PhpClassComponent $b) {
         if ($a::SORT_ORDERING == $b::SORT_ORDERING) {
             return $a->name < $b->name ? -1 : 1;
         }
         return $a::SORT_ORDERING < $b::SORT_ORDERING ? -1 : 1;
     });
     $output = [];
     $lastType = null;
     $lastNumLines = null;
     foreach ($this->classComponents as $component) {
         // manage strategy for adding new lines
         $componentAsLines = $component->content->toArray();
         if (!$lastType || !$component instanceof $lastType) {
             $output[] = "\n";
         } elseif (count($componentAsLines) > 1 or $lastNumLines > 1) {
             $output[] = "\n";
         }
         $lastType = get_class($component);
         $lastNumLines = count($componentAsLines);
         // build the output;
         $output = array_merge($output, $componentAsLines);
     }
     $output[] = "\n";
     return new Format($output);
 }
예제 #2
0
 /**
  * 
  * @see Staple_Query::build()
  */
 function build()
 {
     $stmt = 'UPDATE ';
     //Flags
     if (count($this->flags) > 0) {
         $stmt .= ' ' . implode(' ', $this->flags);
     }
     //Table
     if (is_array($this->table)) {
         $stmt .= ' ';
         //A little extra space
         foreach ($this->table as $alias => $table) {
             $stmt .= $table;
             if (is_string($alias)) {
                 $stmt .= ' AS `' . $alias . '`';
             }
         }
     } else {
         $stmt .= ' ' . $this->table;
     }
     //SET data
     if (count($this->data) >= 0) {
         $stmt .= "\nSET ";
         $stmt .= $this->data->getUpdateString();
     }
     //WHERE CLAUSE
     if (count($this->where) > 0) {
         $stmt .= "\nWHERE " . implode(' AND ', $this->where);
     }
     //Can only order and limit on a single table query
     if (!is_array($this->table)) {
         //ORDER CLAUSE
         if (isset($this->order)) {
             $stmt .= "\nORDER BY ";
             if (is_array($this->order)) {
                 $stmt .= implode(',', $this->order);
             } else {
                 $stmt .= $this->order;
             }
         }
         //LIMIT CLAUSE
         if (isset($this->limit)) {
             $stmt .= "\nLIMIT " . $this->getLimit();
             if (isset($this->limitOffset)) {
                 $stmt .= ' OFFSET ' . $this->limitOffset;
             }
         }
     }
     return $stmt;
 }
예제 #3
0
 /**
  * Esta funcion permite construir el arreglo de datos que necesita el twig para 
  * pintar los datos de busqueda y ordenamiento en pantalla
  * @author Cesar Giraldo <*****@*****.**> 28/08/2015
  * @param array[string] $indexSearch
  * @param array[string] $search
  * @param array[string] $indexOrder
  * @param array[string] $order
  * @param array[string] $paginator
  * @return array[string]
  */
 public static function buildSearcherData($indexSearch, $search, $indexOrder, $order, $paginator, $id = null)
 {
     $params = Paginator::getUrlFromParameters($indexSearch, $search);
     $orderBy = Paginator::getUrlOrderFromParameters($indexOrder, $order);
     $searcherData = array('search' => $search, 'order' => $order, 'params' => $params, 'orderBy' => $orderBy, 'itemsPageUrl' => '&itemsPerPage=' . $paginator->getItemsPerPage($id));
     return $searcherData;
 }