Changeset 6514
- Timestamp:
- 06/15/12 09:32:00 (11 years ago)
- Location:
- sandbox/2.4.1-3/prototype
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.1-3/prototype/api/datalayer.js
r6361 r6514 195 195 196 196 send: function( url, type, data, callback, sync, extraOptions ){ 197 197 198 198 var result = false, fired = false; 199 199 … … 243 243 244 244 $.ajax( envelope ); 245 246 245 return( result ); 247 246 }, … … 260 259 //http://expressodev.prognus.com.br/cristiano/expresso-api/rest/maillast 261 260 //return this.send( ('rest' + uri), [ 'get', accept || 'json' ], data, callback, !!!callback, 261 console.log(this.dispatchPath+'../rest'+uri); 262 262 return this.send( (this.dispatchPath + '../rest' + uri), [ 'get', accept || 'json' ], data, callback, !!!callback, 263 263 {'beforeSend' : function (xhr){ … … 277 277 278 278 create: function( uri, data, callback, accept ){ 279 //return this.send( 'rest' + uri, [ 'post', accept || 'json' ], data, callback, !!!callback, 280 return this.send( (this.dispatchPath + '../rest' + uri), [ 'post', accept || 'json' ], data, callback, !!!callback, 281 {'beforeSend' : function (xhr){ 282 xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 283 }); 279 //return this.send( 'rest' + uri, [ 'post', accept || 'json' ], data, callback, !!!callback, 280 return this.send( (this.dispatchPath + '../rest' + uri), [ 'post', accept || 'json' ], data, callback, !!!callback, 281 {'beforeSend' : function (xhr){ 282 //xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 283 xhr.setRequestHeader('Authorization', "OAUTH Bearer " + (DataLayer.me ? DataLayer.me.token : DataLayer.dispatch("../prototype/me").token))} 284 }); 284 285 }, 285 286 … … 298 299 return this.send( (this.dispatchPath + '../rest' + uri), [ 'put', accept || 'json' ], data, callback, !!!callback, 299 300 {'beforeSend' : function (xhr){ 300 xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 301 //xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 302 xhr.setRequestHeader('Authorization', "OAUTH Bearer " + (DataLayer.me ? DataLayer.me.token : DataLayer.dispatch("../prototype/me").token))} 301 303 }); 302 304 … … 312 314 */ 313 315 314 "delete": function( uri, callback, accept ){ 315 316 delete: function( uri, callback, accept ){ 316 317 //return this.send( 'rest' + uri, [ 'delete', accept || 'json' ], false, callback, !!!callback, 317 318 return this.send( (this.dispatchPath + '../rest' + uri), [ 'delete', accept || 'json' ], false, callback, !!!callback, 318 319 {'beforeSend' : function (xhr){ 319 xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 320 //xhr.setRequestHeader('Authorization', "OAUTH Bearer " + DataLayer.me.token)} 321 xhr.setRequestHeader('Authorization', "OAUTH Bearer " + (DataLayer.me ? DataLayer.me.token : DataLayer.dispatch("../prototype/me").token))} 320 322 }); 321 323 -
sandbox/2.4.1-3/prototype/services/PostgreSQL.php
r6357 r6514 89 89 $map = Config::get($uri['concept'], 'PostgreSQL.mapping'); 90 90 $criteria = ($criteria !== false) ? $this->parseCriteria ( $criteria , $map , ' WHERE '.$map['id'].' = \''.addslashes( $uri['id'] ).'\'') : ' WHERE '.$map['id'].' = \''.addslashes( $uri['id'] ).'\''; 91 91 92 return $this->execSql('UPDATE '.(Config::get($uri['concept'],'PostgreSQL.concept')).' '. self::parseUpdateData( $data ,$map).$criteria); 92 93 } … … 199 200 $val[] = '\''.addslashes($v).'\''; 200 201 } 201 202 // return '('.implode(',', $ind).') VALUES ('.implode(',', $val).') RETURNING '.$map['id'].' as id'; 203 return '('.implode(',', $ind).') VALUES ('.implode(',', $val).') RETURNING id'; 202 return '('.implode(',', $ind).') VALUES ('.implode(',', $val).') RETURNING '.$map['id'].' as id'; 204 203 } 205 204 … … 247 246 $query .= ' GROUP BY '.( is_array($criteria["group"]) ? implode(', ', $criteria["group"]) : $criteria["group"] ).' '; 248 247 } 249 248 250 249 if( isset($criteria["order"]) ) 251 250 { 252 $query .= ' ORDER BY '.self::parseOrder( $criteria["order"], $map ).' '; 253 } 251 //Verificar se os atributos para o ORDER BY serao ordenados em ordem decrescente [DESC] 252 $orderDesc = ( isset($criteria["orderDesc"]) && count($criteria["order"]) == count($criteria["orderDesc"]) ) ? $criteria["orderDesc"] : false; 253 254 $query .= ' ORDER BY '.self::parseOrder( $criteria["order"], $map, $orderDesc ).' '; 255 256 } 257 254 258 if( isset($criteria["limit"]) ) 255 259 { … … 342 346 } 343 347 344 private static function parseOrder($order , &$map)348 private static function parseOrder($order , &$map, $orderDesc=false) 345 349 { 346 350 347 351 if($notArray = !is_array($order)) //Caso seja um full select pegar todas as keys 348 352 $order = array( $order ); 353 354 //Caso seja feita ordenacao em ordem descrescente 355 //concatenar DESC em cada atributo 356 if($orderDesc !== false){ 357 if(!is_array($orderDesc)){ 358 $orderDesc = array( $orderDesc ); 359 } 360 361 for($i=0; $i<count($order); $i++){ 362 $order[$i] .= ($orderDesc[$i] === true) ? ' DESC' : ''; 363 } 364 } 349 365 350 366 $return = array(); … … 359 375 return ( $notArray ? $order[0] : implode(', ', $order) ); 360 376 } 377 361 378 } 362 379
Note: See TracChangeset
for help on using the changeset viewer.