Change a variable from outside it's scope
<pre><code>function get_all_channels_by_order(){
    var foobar = false

    mysql_connection.connect()
    mysql_connection.query("SELECT * FROM channels ORDER BY listorder ASC", function(){
        foobar = true
    })
    mysql_connection.end()
    console.log(foobar)
}
</code></pre>

<p>I need <code>foobar</code> to return <code>true</code> but instead it returns <code>false</code>.
This is due of course to the JavaScript scopes, but I was wondering is there any way to overcome this? Or is it impossible?</p>

<p>I am sorry to ask such a common question, but I have looked at several other Stack Overflow questions and they have not helped, I also tried lots of other code rather than this but no successes.</p>