Example #1
0
static SQRESULT sq_mysql_result_col_value(HSQUIRRELVM v){
	SQ_FUNC_VARS_NO_TOP(v);
	GET_mysql_result_INSTANCE();
	SQObjectType ptype = sq_gettype(v, 2);
	int col = -1;
	if(ptype == OT_STRING){
	    SQ_GET_STRING(v, 2, col_name);
	    col = get_field_idx(self, col_name);
	}
	else
	{
	    SQ_GET_INTEGER(v, 2, idx);
	    col = idx;
	}
	if(col < 0) return sq_throwerror(v, _SC("invalid col index/name"));

    sq_pushstring(v, _curr_row_key, -1);
    if(sq_get(v, 1) == SQ_OK){
        SQ_GET_INTEGER(v, -1, curr_row);
        if(curr_row < dlmysql_num_rows(self)){
        	dlmysql_data_seek(self, curr_row);
        	const MYSQL_ROW res_row = dlmysql_fetch_row(self);
			unsigned long *lengths = dlmysql_fetch_lengths(self);
            sq_pushstring(v, (const SQChar*)res_row[col], lengths[col]);
            return 1;
        }
    }
	return SQ_ERROR;
}
Example #2
0
static SQRESULT sq_mysql_result_col_index(HSQUIRRELVM v){
	SQ_FUNC_VARS_NO_TOP(v);
	GET_mysql_result_INSTANCE();
	SQ_GET_STRING(v, 2, name);
	sq_pushinteger(v, get_field_idx(self, name));
	return 1;
}
Example #3
0
void uds_db_write_cfm(ble_service_t *svc, uint16_t conn_idx, uint32_t field, att_error_t status)
{
        ud_service_t *uds = (ud_service_t *) svc;
        int idx;

        idx = get_field_idx(field);

        if (idx < 0) {
                return;
        }

        ble_gatts_write_cfm(conn_idx, uds->db_val_h[idx], status);
}
Example #4
0
void uds_db_read_cfm(ble_service_t *svc, uint16_t conn_idx, uint32_t field, att_error_t status,
                                                        uint16_t length, const void *value)
{
        ud_service_t *uds = (ud_service_t *) svc;
        int idx;

        idx = get_field_idx(field);

        if (idx < 0) {
                return;
        }

        ble_gatts_read_cfm(conn_idx, uds->db_val_h[idx], status, length, value);
}