Search Results

Search found 1637 results on 66 pages for 'ids'.

Page 5/66 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Select those objects whose related objects IDs are *all* in given string

    - by Jannis
    Hi Django people, I want to build a frontend to a recipe database which enables the user to search for a list of recipes which are cookable with the ingredients the user supplies. I have the following models class Ingredient(models.Model): name = models.CharField(max_length=100, unique=True) slug = models.SlugField(max_length=100, unique=True) importancy = models.PositiveSmallIntegerField(default=4) […] class Amount(models.Model): recipe = models.ForeignKey('Recipe') ingredient = models.ForeignKey(Ingredient) […] class Rezept(models.Model): name = models.CharField(max_length=100) slug = models.SlugField() instructions = models.TextField() ingredients = models.ManyToManyField(Ingredient, through=Amount) […] and a rawquery which does exactly what I want: It gets all the recipes whose required ingredients are all contained in the list of strings that the user supplies. If he supplies more than necessary, it's fine too. query = "SELECT *, COUNT(amount.zutat_id) AS selected_count_ingredients, (SELECT COUNT(*) FROM amount WHERE amount.recipe_id = amount.id) AS count_ingredients FROM amount LEFT OUTER JOIN amount ON (recipe.id = recipe.recipe_id) WHERE amount.ingredient_id IN (%s) GROUP BY amount.id HAVING count_ingredient=selected_count_ingredient" % ",".join([str(ingredient.id) for ingredient in ingredients]) rezepte = Rezept.objects.raw(query) Now, what I'm looking for is a way that does not rely on .raw() as I would like to do it purely with Django's queryset methods. Additionally, it would be awesome if you guys knew a way of including the ingredient's importancy in the lookup so that a recipe is still shown as a result even though one of its ingredients (that has an importancy of 0) is not supplied by the user.

    Read the article

  • How do I get results from a link query in the order of IDs that I provide?

    - by Keltex
    I'm looking to get query results back from Linq in the order that I pass IDs to the query. So it would look something like this: var IDs = new int [] { 5, 20, 10 } var items = from mytable in db.MyTable where IDs.Contains(mytable.mytableID) orderby // not sure what to do here select mytable; I'm hoping to get items in the order of IDs (5, 20, 10). (Note this is similar to this question, but I would like to do it in Linq instead of SQL)

    Read the article

  • not unique ids in a route in Rails

    - by Victor P
    In a blog in Rails I want to have paths like http://mydomain.com/posts/28383/comments#21 This is the 21st comment of the 28383th post. The 21 is not an unique id, but the pair 28383, #21 is unique. How can I do this in Rails? Do I have to change the routes? the model? I will be very thankful if you can point me in the right direction Thanks

    Read the article

  • Multiple remote_form_for on the same page causes duplicate ids

    - by Ben Scheirman
    I've got a rails app that displays a list of items called modules. I'm iterating over these, rendering a partial for each one that includes a remote_form_for call. This all works, but fails HTML validation because my form text fields all have the same id. Is there a :prefix option on the form (or something else) I can use to get around this? Update: (some code) //_module_form.html.erb <% remote_form_for app_module do |f| %> <%= f.label :name %> <%= f.text_field :name %> <%= submit_tag 'Save' %> <%end %> //parent page <% @thing.modules.each do |app_module| %> <%= render :partial => "module_form", :locals => { :app_module => app_module } %> <% end %> So if I have more than 1 item in the collection, I render the identical form on the same page, and the form id and textbox id are duplicated. I can customize the form id pretty easily, but what about the text_box, since the controller is looking for specific named controls?

    Read the article

  • Question about Client IDs

    - by George
    I have a user control that is emmitting javascript using the ClientId function. For example: Out &= "ValidatorHookupControlID(" & Quote & ddlMonth.ClientID & Quote & "), document.all(" & Quote & CustomValidator1.ClientID & Quote & "));" & vbCrLf It appears to me that the ClientID function DOES not return the ultimate ID that is sent to the browser. Instead, the ClientID function only appears to be aware of its current parent control, which in this case is a the User Control and so the ID that is returned is the ID "dtmPassportExpirationDate_ddlMonth" When in fact the usercontrol is included in a master page and the ultimate ID that is used is: "ctl00_phPageContent_dtmPassportExpirationDate_ddlMonth" I may be nuts, but that's what it appears to be doing. I expect that the ClientID function would return the ultimate ID used in the HTML. Am I missing something?

    Read the article

  • Yii, Generate unquie ids one each tr element of CGridView

    - by Snow_Mac
    I have a CDbActiveRecord setup and I have a instance of the CGridView class setup as a widget. Basically my end game is I need a table, but each row to contain the primary key of the row associated with the Active Record. Such as: <tr id="123"> <td> Column value 1 </td> <td> Col 2 </td> <td> Col 3 </td> </tr> That's the specific of the row that I'm looking for. Here's the code I've got so far to produce a table. (The json variable is set because this is inside a controller and the widget is returned as json.) // get the content id for the version list $contentID_v = Yii::app()->request->getParam("id"); // setup the criteria to fetch related items $versionCdbCriteria = new CDbCriteria; $versionCdbCriteria->compare("contentID",$contentID_v); // setting up the active data provider for the version $vActiveDP = new CActiveDataProvider("FactsheetcontentVersion", array( "criteria" => $versionCdbCriteria, 'pagination' => array('PageSize' => $this->paginationSize), 'keyAttribute'=>'vID', )); $json_data .= $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider' => $vActiveDP, 'columns' => array( 'title', 'created', 'createdBy' ), 'showTableOnEmpty' => 'false', ),true); This is what it produces for my active record. <div class="grid-view" id="yw0"> <div class="summary">Displaying 1-1 of 1 result(s).</div> <table class="items"><thead> <tr><th id="yw0_c0">Factsheettitle</th> <th id="yw0_c1"><a href="jq/work/admin/index.php?r=factsheetManager/Editor &amp;id=25601&amp;getV=true&amp;_=1341694154760&amp;FactsheetcontentVersion_sort=created">Created</a> </th> <th id="yw0_c2"><a href="jq/work/admin/index.php?r=factsheetManager/ Editor&amp;id=25601&amp;getV=true&amp;_=1341694154760&amp;FactsheetcontentVersion_sort=createdBy">Created By</a> </th> </tr></thead> <tbody><tr class="odd"><td>Distribution</td><td>0000-00-00 00:00:00</td><td>NULL</td></tr></tbody> </table> <div title="jq/work/admin/index.php?r=factsheetManager/Editor&amp;id=12&amp;id=25601&amp;getV=true&amp;_=1341694154760" style="display:none" class="keys"><span>8</span></div> </div>

    Read the article

  • Eclipse - Force Refresh of IDs

    - by Echilon
    I'm using eclipse for Android development, and the editor always seems to take a while to actually update and recognize if I change an ID in a layout, then try to use it in a class with R.id.someId. Is there a way to force a refresh?

    Read the article

  • Hibernate Query for a List of Objects that matches a List of Objects' ids

    - by sal
    Given a classes Foo, Bar which have hibernate mappings to tables Foo, A, B and C public class Foo { Integer aid; Integer bid; Integer cid; ...; } public class Bar { A a; B b; C c; ...; } I build a List fooList of an arbitrary size and I would like to use hibernate to fetch List where the resulting list will look something like this: Bar[1] = [X1,Y2,ZA,...] Bar[2] = [X1,Y2,ZB,...] Bar[3] = [X1,Y2,ZC,...] Bar[4] = [X1,Y3,ZD,...] Bar[5] = [X2,Y4,ZE,...] Bar[6] = [X2,Y4,ZF,...] Bar[7] = [X2,Y5,ZG,...] Bar[8] = ... Where each Xi, Yi and Zi represents a unique object. I know I can iterate fooList and fetch each List and call barList.addAll(...) to build the result list with something like this: List<bar> barList.addAll(s.createQuery("from Bar bar where bar.aid = :aid and ... ") .setEntity("aid", foo.getAid()) .setEntity("bid", foo.getBid()) .setEntity("cid", foo.getCid()) .list(); ); Is there any easier way, ideally one that makes better use of hibernate and make a minimal number of database calls? Am I missing something? Is hibernate not the right tool for this?

    Read the article

  • php / mysql - select id from one table excepting ids which are in second table

    - by John
    hello. for example i have 2 tables: 1 . users: id Name 1 Mike 2 Adam 3 Tom 4 John 5 Andy 6 Ray 2 . visits: userID date 1 ... 3 ... 6 ... i want to make a page which can be visited once in 12 hours, when user visits that page his id is included in database ( visits ), how i can select all users ( from database users) excepting users who visited page in <= 12 hours ( users from database visits )?

    Read the article

  • nhibernate mapping: delete collection, insert new collection with old IDs

    - by npeBeg
    my issue lokks similar to this one: (link) but i have one-to-many association: <set name="Fields" cascade="all-delete-orphan" lazy="false" inverse="true"> <key column="[TEMPLATE_ID]"></key> <one-to-many class="MyNamespace.Field, MyLibrary"/> </set> (i also tried to use ) this mapping is for Template object. this one and the Field object has their ID generators set to identity. so when i call session.Update for the Template object it works fine, well, almost: if the Field object has an Id number, UPDATE sql request is called, if the Id is 0, the INSERT is performed. But if i delete a Field object from the collection it has no effect for the Database. I found that if i also call session.Delete for this Field object, everything will be ok, but due to client-server architecture i don't know what to delete. so i decided to delete all the collection elements from the DB and call session.Update with a new collection. and i've got an issue: nhibernate performs the UPDATE operation for the Field objects that has non-zero Id, but they are removed from DB! maybe i should use some other Id generator or smth.. what is the best way to make nhibernate perform "delete all"/"insert all" routine for the collection?

    Read the article

  • How do I get results from a Linq query in the order of IDs that I provide?

    - by Keltex
    I'm looking to get query results back from Linq in the order that I pass IDs to the query. So it would look something like this: var IDs = new int [] { 5, 20, 10 } var items = from mytable in db.MyTable where IDs.Contains(mytable.mytableID) orderby // not sure what to do here select mytable; I'm hoping to get items in the order of IDs (5, 20, 10). (Note this is similar to this question, but I would like to do it in Linq instead of SQL)

    Read the article

  • Creating controls in ASP with dynamic IDs

    - by mattdell
    Hi, I'm creating a chat widget that will be dropped into CommunityServer. The widget works great, but I just discovered that if I drop two of these widgets onto the same page, only one of them works! And I'm quite certain the reason is because the chat window is defined in ASP, and now there are two instances of the chat window, with the same ID, on the same page. I am doing this with straight ASP & Javascript (not by choice), so my chat window is defined as: <telerik:RadListBox ID="rlbMessages" runat="server" > (don't mind that it's a telerik control). So I was hoping I could do something like this: <telerik:RadListBox ID="<%= 'rlbMessages' + chatRoomID %>" runat="server" > But from what I've gathered, apparently you can't assign ID's this way? What is the alternative?

    Read the article

  • Best way to perform DELETE that uses ids from a SELECT statement in MYSQL

    - by Aglystas
    I'm working on a stored procedure, that needs to delete specific rows based on a timestamp. Here's what I was going to use until I found out you can't include a select clause in the delete statement if they are both working on the same table. DELETE FROM product WHERE merchant_id = 2 AND product_id IN (SELECT product_id FROM product WHERE merchant_id = 1 AND timestamp_updated > 1275062558); Is there a good way to handle this within a stored procedure. Normally I would just throw the logic to build the product_id list in php, but I'm trying to have all the processing done on the data server.

    Read the article

  • Glassfish complaining about JSF component IDs

    - by Brian
    Hello All I am very new to JSF (v2.0) and I am attempting to learn it at places like netbeans.org and coreservlets.com. I am working on a very simple "add/subtract/multiply/divide" Java webapp and I have run into a problem. When I first started out, the application was enter two numbers and hit a '+' key and they would be automatically added together. Now that I have added more complexity I am having trouble getting the operation to the managed bean. This is what I had when it was just "add": <h:inputText styleClass="display" id="number01" size="4" maxlength="3" value="#{Calculator.number01}" /> <h:inputText styleClass="display" id="number02" size="4" maxlength="3" value="#{Calculator.number02}" /> <h:commandButton id="add" action="answer" value="+" /> For the "answer" page, I display the answer like this: <h:outputText value="#{Calculator.answer}" /> I had the proper getters and setters in the Calculator.java managed bean and the operation worked perfectly. Now I have added the other three operations and I am having trouble visualizing how to get the operation parameter to the bean so that I can switch around it. I tried this: <h:commandButton id="operation" action="answer" value="+" /> <h:commandButton id="operation" action="answer" value="-" /> <h:commandButton id="operation" action="answer" value="*" /> <h:commandButton id="operation" action="answer" value="/" /> However, Glassfish complained that I have already used "operation" once and I am trying to use it four times here. Any adivce/tips on how to get multiple operations to the managed bean so that it can preform the desired operation? Thank you for taking the time to read.

    Read the article

  • Assigning IDs to instances of a class (Pythonic)

    - by mellort
    I want to have each instance of some class have a unique integer identifier based on the order that I create them, starting with (say) 0. In Java, I could do this with a static class variable. I know I can emulate the same sort of behavior with Python, but what would be the most 'Pythonic' way to do this? Thanks

    Read the article

  • jQuery: how to pick unique IDs ?

    - by Seerumi
    Hello. New to whole this jQuery (and javascript altogether, heh) and so far it's been excellent, but now I'm in a small pickle. Let's say I have list of forms generated from SQL database and every single one of them has to have unique id, so how I can select the specific item that is to be manipulated (changing values via php). the $("#submit").click(function()) will trigger every submit buttons on the page, so how I can the #submit to be some random id that I clicked. There might be a smarter way, but I'm new to this so try to bear with me. thought of passing the unique value with onClick="myfunction(unique_id)", but don't know how it goes with jQuery. hope this made any sense

    Read the article

  • Should i really use integer primary IDs [sql]

    - by arthurprs
    For example, i always generate an auto-increment field for the users table, but i also specifies an UNIQUE index on their usernames. There is situations that i first need to get the userId for a given username and then execute the desired query. Or use a JOIN in the desired query. It's 2 trips to the database or a JOIN vs. a varchar index The above is just an example There is a real performance benefit on INT over small VARCHAR indexes? Thanks in advance!

    Read the article

  • JQuery going through a set of UL and dynamically set ids incremently on each one

    - by Calibre2010
    I have an unordered list which contains serveral items called 'oListItems' the UL has a class but no id. The class OuteroListItems contains many of oListitems oList.AppendFormat("<ul class='OuteroListItems'>"); oList.AppendFormat("<li>"); oList.AppendFormat("<ul class='oListItems'>"); oList.AppendFormat("<li>" + s.sName + "</li>"); oList.AppendFormat("<li>" + s.eName + "</li>"); oList.AppendFormat("<li>" + s.SDate + "</li>"); oList.AppendFormat("<li>" + s.EDate + "</li>"); oList.AppendFormat("</ul>"); oList.AppendFormat("</li>"); oList.AppendFormat("</ul>"); I want for each .oListItem class that gets retrieved, add dynamically an id to it. var o = $(".oListItem"); $.each(o, function (){ var f = $(this).attr("id", 'listItem' + i); i++; }); wasent sure on the approach, this is what I have so far?

    Read the article

  • Loading a entity IDs CSV column as hydrated entities in NHibernate

    - by James L
    I have a number of database table that looks like this: EntityId int : 1 Countries1: "1,2,3,4,5" Countries2: "7,9,10,22" I would like to have NHibernate load the Country entities identifed as 1,2,3,4,5,7,9 etc. whenever my EntityId is loaded. The reason for this is that we want to avoid a proliferation of joins, as there are scores of these collections.

    Read the article

  • Setting up App Engine to receive email addresses with ids in the address

    - by Mark M
    I am writing an App Engine app that is supposed to receive emails in this form: [email protected] (someID is an alphanumeric ID that I generate). I have this in my web.xml thinking it would catch emails that start with 'addcontact.': <servlet> <servlet-name>addNewContactServlet</servlet-name> <servlet-class>com.mycompany.server.AddNewContactServlet</servlet- class> </servlet> <servlet-mapping> <servlet-name>addNewContactServlet</servlet-name> <url-pattern>/_ah/mail/addcontact.*</url-pattern> </servlet-mapping> However, both on my dev machine and on google's servers email is not received. On the dev machine I get this message (I get a similar error in the deployed log) Message send failure HTTP ERROR 404 Problem accessing /_ah/mail/ [email protected]. Reason: NOT_FOUND I can receive email at fully specified addresses or when I use /_ah/mail/* The google documentation made me believe it was possible to include partial email addresses in web.xml. Am I not using the wildcard correctly? Does the period have something to do with it? Can this be done somehow?

    Read the article

  • Return multiple IDs from a function and use the result in a query

    - by NewK
    I have this function that returns me all children of a tree node: CREATE OR REPLACE FUNCTION fn_category_get_childs_v2(id_pai integer) RETURNS integer[] AS $BODY$ DECLARE ids_filhos integer array; BEGIN SELECT array ( SELECT category_id FROM category WHERE category_id IN ( (WITH RECURSIVE parent AS ( SELECT category_id , parent_id from category WHERE category_id = id_pai UNION ALL SELECT t.category_id , t.parent_id FROM parent INNER JOIN category t ON parent.category_id = t.parent_id ) SELECT category_id FROM parent WHERE category_id <> id_pai ) ) ) into ids_filhos; return ids_filhos; END; and I would like to use it in a select statement like this: select * from teste1_elements where category_id in (select * from fn_category_get_childs_v2(12)) I've also tried this way with the same result: select * from teste1_elements where category_id=any(select * from fn_category_get_childs_v2(12))) But I get the following error: ERROR: operator does not exist: integer = integer[] LINE 1: select * from teste1_elements where category_id in (select *... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. The function returns an integer array, is that the problem? SELECT * from fn_category_get_childs_v2(12) retrieves the following array (integer[]): '{30,32,34,20,19,18,17,16,15,14}'

    Read the article

  • using same ids for many tags?

    - by gaurav rathor
    here is the example code that i was testing and i got confused that every one says that we can use or we should use only one time per id but i have testes using using it multiple times but its giving me the correct output. so what should i do. it is kinda working same like class for me in this example code: <html> <head> <style> #exampleID1 { background-color: blue; } #exampleID2 { text-transform: uppercase; } </style> </head> <body> <p id="exampleID1">This paragraph has an ID name of "exampleID1" and has a blue CSS defined background.</p> <p id="exampleID2">This paragraph has an ID name of "exampleID2" and has had its text transformed to uppercase letters.</p> <address id="exampleID1"> Written by W3Schools.com<br /> <a href="mailto:[email protected]">Email us</a><br /> Address: Box 564, Disneyland<br /> Phone: +12 34 56 78 </address> <blockquote id="exampleID1"> Here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation. </blockquote> </body> </html> please see the above code and answer me that why we should not use id selector two times in a page while its working fine.

    Read the article

  • Get dialog input field IDs in CKEditor

    - by rt-uk
    Each input field in the CKEditor dialogs are renamed with a unique number, but the number changes depending on what options are visible. I need to reference 'txtUrl' which has an id something like #35_textInput. So far I have discovered that something like this should work: alert(CKEDITOR.instances.myElement.document.$.body.getId('txtUrl')); But it doesn't. Please help.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >