parent-child

Recursively check the parents of a child in a database

て烟熏妆下的殇ゞ 提交于 2019-12-03 21:22:37
I'm working on a CMS system that receives urls like this: /parent1/parent2/child/ Now it's easy to check only the child but in my opinion you should also check if the parents are correct and in the right order. The problem is that I'm unsure on how to do this. I'm using mysql. this is how that table would look: CREATE TABLE IF NOT EXISTS `pages` ( `id` int(11) NOT NULL auto_increment, `parent` int(11) NOT NULL default '0', `title` varchar(255) NOT NULL, `deleted` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; the parent field keeps

Delete a child and a parent row with one SQL script

时光毁灭记忆、已成空白 提交于 2019-12-03 20:42:56
问题 Instead of deleting the child row and then writing another sql statement to delete the parent row I wanted to use one statement which will do both. FYI: we use Oracle database. Update: I dont have a privilege to do DELETE ON CASCADE 回答1: Define your foreign keys with cascading deletes. Then you only need to delete the "parent" row. 回答2: delete from ( select * from parent join child using (id) where id = 1 ) WARNING! Will only delete where both parent AND child rows exist. Will NOT delete

NHibernate.StaleStateException : Unexpected row count: 0; expected: 1

安稳与你 提交于 2019-12-03 19:59:27
问题 Hl Guys, I am busy writing a backend administrative program for a system that exists. I have selected NHibernate for my data access solution and am fairly new to it. I am experiencing the following error in a parent/child relationship: NHibernate.StaleStateException : Unexpected row count: 0; expected: 1 This error is caused by the fact that in my source code I add the new child object into the parent’s children collection of MeetingAdministrators. When I save the parent object I expect the

How to pass data (selected item) to Durandal composed detail view?

為{幸葍}努か 提交于 2019-12-03 17:45:45
问题 I've started using (as of, a few hours ago) Durandal with the hope to manage views and allow composition within a single page - the previous approach, also using Knockout, was getting too unwieldy to maintain in a fat HTML file. I've installed/setup Durandal and I can create views and viewmodels - however, I don't know how to get data into the viewmodel to use as a basis for the new viewmodel. For instance, I have a "left nav bar" for selecting items - when an item is selected it updates a

Nested parent/child checkboxes - working solution need adjustment help for Bootstrap

巧了我就是萌 提交于 2019-12-03 17:41:38
问题 I have been looking for a 'complete' solution to nesting parent child checkboxes that change state correctly based on a hierarchy. Most 'solutions' do not work or only work to one level. They also require you to name the checkboxes in a particular way. This Stack Overflow discussion covers the main points but also provide a good solution discovered by Rory here. I have tested it within my development project and it works perfectly standalone. However, I am using Bootstrap 2.x and for

Delete a child record from the parent collection

被刻印的时光 ゝ 提交于 2019-12-03 17:35:16
问题 I'm developing a sample application so that I can learn the ins and outs of NHibernate. I am struggling with a delete issue. I wish to be able to delete a child record by removing it from its parent’s collection and then saving the parent. I have setup a bidirectional one-to-many relationship and inserting/updating is working great. Here are my mappings Basket: <bag name="Items" inverse="true" cascade="all"> <key column="BasketId" /> <one-to-many class="BasketItem" /> </bag> BasketItem: <many

JPA mapping for Parent-Child with same class

故事扮演 提交于 2019-12-03 16:56:37
问题 I have following table: FOLDER[ id int, name varchar2(10), parent_folder_id int ] I would like to have Folder class to have parent-child relationship. 回答1: I believe the correct mapping would be: @Entity public class Folder { @Id @Column(name="PK_FOLDER") private int id; @Column(name="NAME") private String name; @ManyToOne @JoinColumn(name="FK_PARENT_FOLDER") public Folder parentFolder; @OneToMany(mappedBy="parentFolder") public List<Folder> subFolders = new ArrayList<Folder>(); } The

Difference between javascript .childNodes & .children

别等时光非礼了梦想. 提交于 2019-12-03 15:07:44
I have been working with javascript for a week now. I am currently working on making things work/change through nodes. But I have been noticing something strange, well for an unskilled javascripter it is. I have a structure in my site like this: <html> <head> <title>....</title> <link/> <script></script> </head> <body> <div 1> <div 2></div> </div> </body> </html> When I am trying to find a childnode with the next function: var headerBox = document.body.childNodes; var txt = ""; for (var x = 0; x < headerBox.length; x ++) { txt =txt+"Childnode["+x+"]: "+headerBox[x].localName+" ("+headerBox[x]

Rails - Parent/child relationships

£可爱£侵袭症+ 提交于 2019-12-03 11:11:46
I'm currently using a standard one-to-one relationship to handle parent/child relationships: class Category < ActiveRecord::Base has_one :category belongs_to :category end Is there a recommended way to do it or is this ok? You will need to tweak the names you are using to get this working - you specify the name of the relationship, and then tell AR what the class is: class Category < ActiveRecord::Base has_one :child, :class_name => "Category" belongs_to :parent, :class_name => "Category" end has_many version: class Category < ActiveRecord::Base has_many :children, :class_name => "Category"

How to retrieve parent node using XQuery?

 ̄綄美尐妖づ 提交于 2019-12-03 09:34:42
I am using XML and XQuerie. I usually use an XPath expression relative to a parent node to retrieve its child node. But, I am not sure how to do the opposite meaning if I have a child node, how do I retrieve its parent node. <node id="50> <childnode1 childid="51" /> <childnode2 childid="52" /> </node> If I have the node <childnode1 childid="51" /> , how do I retrieve its parent: <node id="50> Short answer : .. This selects the parent of the current (context) node. Longer and more general answers : //node()[childnode1/@childid="51"] This selects any node in the document that has a child element