Example #1
0
function format( data, type ){

	try{

		var where = '',
			limit = '',
			update = '',
			_s = '';
		
		if( isNaN( data.start - 0 ) ){
			data.start = 0;
		}

		if( isNaN( data.limit - 0 ) ){
			data.limit = 15;
		}

		limit = ' limit ' + ( data.start ) + ', ' + ( data.limit );

		delete data.start;
		delete data.limit;

		if( type == 'update' ){
			for( var key in data ){
				_s ? _s += ', ': _s;
				_s +=  key + '=' + client.escape( data[key] ) + '';
			}
			update = _s;
		} else {
			for( var key in data ){
				_s ? _s += ' and ': _s;
				_s += '' + key + '=' + client.escape( data[key] );
			}
			where = _s ? ' where ' + _s : _s ;
		}
		return { where: where, limit: limit, update: update };
	
	} catch (e){
		
	}
}