Skip to content

Instantly share code, notes, and snippets.

@mbahar
Created September 14, 2013 07:27
Show Gist options
  • Save mbahar/6559617 to your computer and use it in GitHub Desktop.
Save mbahar/6559617 to your computer and use it in GitHub Desktop.
sample
// Query the database.
console.log(deneme);
db.executeSQL('SELECT * FROM tl_evaluation WHERE evaluation_id= ' +evaluation_id,queryParameters,sqlEndingClause,
function (rows) {
// get avaluation cycle info
db.executeSQL('SELECT * FROM tl_evaluation_cycle WHERE cycle_id=' +rows[0].evaluation_cycle_id ,queryParameters,sqlEndingClause,
function (cycle) {
rows[0].evaluation_cycle_name = cycle[0].cycle_desc;
console.log(cycle);
});
db.executeSQL('SELECT field_id, field_data_value AS value, field_option_id FROM tl_field_data WHERE entity_id = 1 AND entity_key_value= ' +evaluation_id ,queryParameters,sqlEndingClause,
function (field_data) {
rows[0].field_data = field_data;
for(var i = 0; i < rows[0].field_data.length; i++)
rows[0].field_data[i].value = new Buffer( rows[0].field_data[i].value, 'binary' ).toString();
// User roles in evaluation and related user info
db.executeSQL('SELECT user_id FROM tl_evaluation_user_rl WHERE evaluation_id = ' +evaluation_id + " ORDER BY evaluation_role_id",queryParameters,sqlEndingClause,
function (roles) {
rows[0].observer_id = roles[0] != null ? roles[0].user_id : '';
rows[0].observed_id = roles[1] != null ? roles[1].user_id : '';
rows[0].reviewer_id = roles[2] != null ? roles[2].user_id : '0';
db.executeSQL('SELECT u.user_name, u.avatar FROM tl_user u, tl_evaluation_user_rl rl WHERE rl.user_id = u.user_id and rl.evaluation_id = ' +evaluation_id,queryParameters,sqlEndingClause,
function (users) {
rows[0].users = users;
//console.log(rows[0]);
request.reply (JSON.stringify(rows[0]));
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment