& ldquo; & quot; and & ldquo; NOT IN & ldquo; in CakePHP 3

This question already has an answer here: Access variables from parent scope in anonymous PHP function 1 answer There is an example in the Cookbook: $query = $cities->find() ->where(function ($exp, $q) { return $exp->notIn('country_id', ['AFG', '

Javascript - range chain

I read a number of articles about the javascript scope chain and I thought I had a decent understanding of it. However, a very simple exercise made me realize I do not yet understand it at all. I created the following code. function foo () { var b =

PHP calls two functions but save the variable of the first?

i am trying to set a title with the function below and then call another function so i can render the view but after I cannot see the title. here is my code: snippet from another file: $indexPage = new View(); $indexPage->setPageTitle('This is the ti

Use polymorphic associations with the default scope

I am contributing one of the ruby on rails application over GitHub where I faced the following scenario: I am having following models which I want to convert to make polymorphic: class Comment < ActiveRecord::Base belongs_to :team belongs_to :project

subroutine taking an array as a parameter in Java

In the following program, the user is supposed to enter a String (name of a City) and the program should return the index of the corresponding City in the array. But I get an error, in the subroutine indexCities the following message: "nameCity canno

OR scope and operator in Javascript

I walked on something weird while doing some JS code today. I wanted to execute an object's method if the property existed, and some other function if it didn't. Feeling a little bit fancy, I wrote something like: var obj = { method: function(){ cons

How to display only tags used by a user

I am writing a Rails 4.2 app with models user, notecard, tag and tagging (for the m-2-m relationship). A tag can have multiple notecards and a notecard can have multiple tags. A card belongs to a user and a tag DOESN'T belong to a user. How can I sco

Access a non-static public object from another distinct class

I am trying to create my own Font Chooser class in another separate class from the file where I have my main class (a JFrame application), and I would like to access to the textArea object of the main JFrame, in order to modify its font properties, b

Bewildering behavior on the scope of the function

I am new to javascript and while I was practicing scope I tried the following code: var il = "inner"; var o ="outer"; var of = function(){ console.log(o + " " + il); o = "baher"; var il = "ander"; console.

Rails 4: Multiple joins with the scope

The following ERD includes the classes involved in the question. Here are the code of the 3 main classes (Monitoring, Link and Story). class Monitoring < ActiveRecord::Base belongs_to :company has_many :keywords, through: :monitoring_keywords has_man

Mule variable expression scope

What is the scope of variables in Mule expression components, and how does that relate to flow variables? I had a flow with a set-variable and was surprised to see that the value was being overwritten by an assignment in an expression-component. For

PHP table empty outside the function

This question already has an answer here: Reference: What is variable scope, which variables are accessible from where and what are "undefined variable" errors? 3 answers <?php echo '<pre>'; error_reporting(E_ALL); $pid = '129'; $famili

Is it wrong to add instance variables to a controller?

If I want to share an object between multiple methods in a controller, is it wrong to create an instance var? E.g. class MyController { def index() { def user = verifyUserLogin() [messages:getMessages(user)] } private verifyUserLogin() { ... return u

private [foo] applies to any foo-based package?

A long shot, but putting it out there -- looking for a way to provide privacy based on a common relative package scope. So, for example, is there a way to use private[foo] for packages com.company1.foo and com.company2.foo where each package will hav

Mechanics of memory with scope

If I do something like // global scope function stuff() { // local scope var a = new SomeHugeMemoryHog(); } // a doesn't exist down here, but what happened to the memory from the "stuff" scope? Will I create a memory leak if I don't set a = null

Destroyer not be called when leaving the scope

I am learning memory management in C++ and I don't get the why only some of the destructors are called when leaving scope. In the code below, only obj1 destructor is called when myfunc ends, not for the dynamically allocated obj2. int myfunc (cl1 *oa

Scope of modules / functions imported in Python

I'm new here and am not 100% sure how to ask this question so I'll just dive right in. Should I be using import statements at the beginning of every function I write that import all of the various modules/functions I need for that function's scope? i

Rails helper for views and controllers?

I know there are ways to make helpers available to controllers, but that this is generally bad form. How should the following be re-worked to avoid this? I have a Contacts helper called "fullname" that combines a contact's first and last names.

How to get jquery callback data to the parent function

I'm using the jquery ui drag/drop code. Upon a drop a getJSON request gets executed to check the new data and update the database. This works fine, until my backend return an error, because I can't cancel the drop from within the anonymous function.

JS variable range

Variable scope in JS is confusing the hell out of me. In follwing code, if i use the setClient public method to set a clientID i can then access the value from inside the track method using the getClient method. I cannot however access the value of t