Example #1
0
 private function _get_typed_value($key, $direction = 'get')
 {
     $data = $this->_data[$key];
     // Tipo de saída
     $type_data = isset($data['type']) ? $data['type'] : array('default', null, true);
     $type_data[0] = $type_data[0] ? $type_data[0] : 'default';
     // Retorna o valor tipado
     return core_types::type_return($this->_conn, $type_data[0], $data['internal'], $type_data[1], $type_data[2], $direction);
 }
Example #2
0
 public static function query($conn, $query, $from = null, $args = null, $row = null)
 {
     $query = self::parse_query($query);
     $query_string = null;
     foreach ($query as $data) {
         // Se for uma string, apenas copia
         if (is_string($data)) {
             $query_string .= $data;
             continue;
         }
         switch ($data['object']) {
             // Se for um object this
             case 'this':
                 $query_string .= '`' . $conn->escape($from->table()) . '`';
                 continue 2;
                 // Se for uma variável
             // Se for uma variável
             case 'variable':
                 // Define a informação que será passada
                 // Se for uma variável do objeto [@this.id]...
                 // Em casos comuns, usa o argumento informado
                 $variable_data = isset($data['this']) ? $row->__get($data['name']) : @(ctype_digit($data['name']) ? $args[$data['name'] - 1] : $args[$data['name']]);
                 $data_type = isset($data['type']) ? $data['type'] : 'string';
                 $query_string .= core_types::type_return($conn, $data_type, $variable_data, @$data['optional'], @$data['null']);
                 continue 2;
         }
     }
     return $query_string;
 }