On the advice of a more experienced developer, I have always coded my web pages that require user input (form processing, database administration, etc.) as self-referential pages. For PHP pages, I set the action of the form to the 'PHP_SELF' element of the $_SERVER predefined variable, and depending on the arguments that I pass the page ...
I have a self-referential MySQL table with a recursive parent_id:
CREATE TABLE `recursive` (
`id` int(11) NOT NULL auto_increment,
`parent_id` int(11) default NULL,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
KEY `data_categorysource_parent_id` (`parent_id`),
CONSTRAINT `parent_id_refs_id_627b4293`
FOREIGN KEY (`p...
If I define a function:
def f(x):
return x+3
I can later store objects as attributes of the function, like so:
f.thing="hello!"
I would like to do this from inside the code of the function itself. Problem is, how do I get a reference to the function from inside itself?
...
I would like to better understand the differences for checking uniqueness in a record before an INSERT between using CHECKSUM (with unique constraints) versus self-referencing table statement like the one below. What scenarios would pose one option to be the best choice over the other, and for what reasons?
Requirement: Each set of colu...
Hi there,
I'm having trouble understanding how to get the following working in interface builder.
I've created a Core Data model class "Person" that has a number of attributes (first name, surname, etc.) and a relationship to other persons (friends).
Conceptually this is very simple. However figuring out how to get this working in IB ...
Hi,
What type of collection would be best in C# to implement the following requirements do you think?
Need to model web file (e.g. class = "webfile"), so one class only preferred
Model parent & child relationship - In terms of associations a webfile can have multiple child webfiles, and child webfiles can have multiple parents. (thin...
I want to (as an example) create a has_many association to all posts by friends of a person, something like has_many :remote_posts to give me something like person > friends > person > posts.
..here is how I would go about it
script/generate model post title:string person_id:integer
script/generate model friendship person_id:integer f...
My Core Data model contains an entity, Shape, that has two self-referential relationships, which means four properties. One pair is a one-to-many relationship (Shape.containedBy <->> Shape.contains) and the another is a many-to-many relationship (Shape.nextShapes <<->> Shape.previousShapes). It all works perfectly in the application, so ...
I have model called test, and test can have many tests, and should be able to have a reference to it's parent test if it exists. EG
test <-- parent doesn't exist
test
test
test
test
test
test
test <-- parent doesn't exist
i've seen a couple of possible solutions with examples before 2.3, but how models handle references seems t...
I'm using a self referencing HABTM model with Participants. You sign up for an event and when you log in to your reservation/profile you see a list of other participants and you can choose to add yourself and others into various groups; share hotel room, share transportation from airport etc.
What I've managed so far:
1) In my profile...
Let's say you have the following table:
items(item_id, item_parent)
... and it is a self-referencing table as item_parent refers to item_id.
What MySQL supported SQL query would you use to SELECT each item in the table along with a boolean value that indicates whether that item is a parent / has other items referencing to it?
If you ha...
I have written an application for an online clothing store in Rails 2.3.5. I want to show related Products when a customer views the Product Detail page.
For example, if the customer views the detail page for a suit, I'd like to display the accessory products that match the dress such as a vest, shoes, and belt. I have named the relat...
Taking Ryan Bates' asciicast as an example:
http://asciicasts.com/episodes/163-self-referential-association
He ends with two associations of User
:friends
:inverse_friends
Given that a user would not care who instigated the friendship, you would want a User association that was simply
:friends
that consisted of both relationship...
Suppose you have the following table, intended to represent hierarchical data:
+--------+-------------+
| Field | Type |
+--------+-------------+
| id | int(10) |
| parent | int(10) |
| name | varchar(45) |
+--------+-------------+
The table is self-referential in that the parent_id refers to id.
So you might ha...
class Addressee < AR::Base
end
class Employee < Addressee
belongs_to :person
belongs_to :company
end
class Person < Addressee
has_many :employees
has_many :companies, :through => :employees
end
class Company < Addressee
has_many :employees
has_many :people, :through => :employees
end
Given the models above, when I ru...
What type T makes the following code compilable?
T f(){ return &f; }
I'd prefer a C answer, but I marked the question as C and C++ in case there is only an answer using templates.
...
I know there's an easy way of doing this, but my recursion abilities are out of practice. Given a database table that has three fields:
id
label
child_id
I should be able to put together a recursive function that will give output like this:
child (input of program)
parent1
parent2
grandparent1
great-grandparent1
gr...
I have a many-to-many model, following the example in this great railscast
My model links authors to each other. I'd like to validate that an author cannot friend himself. I know I can handle this at the UI level, but I'd love to have a validation in place to prevent a bug in the UI from allowing it. I've tried validates_exclusion_of, b...
Hey Team,
I'm playing around with different JS design patterns, and im trying to modify some samples I've seen out there. I saw an example of a xhr factory, that had several nested try/catch statements that were nested within eachother.
try{
...
}catch(e){
try{
...
}catch(e){}
}
I figured I'd be able to do a self-invoking...
Say I have four tables:
------------- features --------------
id: int
name: varchar
-------------------------------------
-------- feature_categories ---------
feature_id: int
category_id: int
-------------------------------------
----------- categories --------------
id: int
name: varchar
-------------------------------------...