Search Results

Search found 7391 results on 296 pages for 'record locking'.

Page 41/296 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Bidirectional replication update record problem

    - by Mirek
    Hi, I would like to present you my problem related to SQL Server 2005 bidirectional replication. What do I need? My teamleader wants to solve one of our problems using bidirectional replication between two databases, each used by different application. One application creates records in table A, changes should replicate to second database into a copy of table A. When data on second server are changed, then those changes have to be propagated back to the first server. I am trying to achieve bidirectional transactional replication between two databases on one server, which is running SQL Server 2005. I have manage to set this up using scripts, established 2 publications and 2 read only subscriptions with loopback detection. Distributtion database is created, publishment on both databases is enabled. Distributor and publisher are up. We are using some rules to control, which records will be replicated, so we need to call our custom stored procedures during replication. So, articles are set to use update, insert and delete custom stored procedures. So far so good, but? Everything works fine, changes are replicating, until updates are done on both tables simultaneously or before changes are replicated (and that takes about 3-6 seconds). Both records then end up with different values. UPDATE db1.dbo.TestTable SET Col = 4 WHERE ID = 1 UPDATE db2.dbo.TestTable SET Col = 5 WHERE ID = 1 results to: db1.dbo.TestTable COL = 5 db2.dbo.TestTable COL = 4 But we want to have last change winning replication. Please, is there a way to solve my problem? How can I ensure same values in both records? Or is there easier solution than this kind of replication? I can provide sample replication script which I am using. I am looking forward for you ideas, Mirek

    Read the article

  • Re-use of database object in sub-sonic

    - by cantabilesoftware
    Yet another newbie SubSonic/ActiveRecord question. Suppose I want to insert a couple of records, currently I'm doing this: using (var scope = new System.Transactions.TransactionScope()) { // Insert company company c = new company(); c.name = "ACME"; c.Save(); // Insert some options company_option o = new company_option(); o.name = "ColorScheme"; o.value = "Red"; o.company_id = c.company_id; o.Save(); o = new company_option(); o.name = "PreferredMode"; o.value = "Fast"; o.company_id = c.company_id; o.Save(); scope.Complete(); } Stepping through this code however, each of the company/company_option constructors go off and create a new myappDB object which just seems wasteful. Is this the recommended approach or should I be trying to re-use a single DB object - and if so, what's the easiest way to do this?

    Read the article

  • Simple way to use Foreign Key values for sorting?

    - by Brian Rizzo
    Disclaimer: I jumped to C# 2008 recently and SubSonic 3 (3.0.0.4) at the same time. I haven't used Linq for much of anything in the past. Is there an easy way to use the foreign key display value for sorting, rather than the FK Id (which is numeric)? I've added a new Find method in my ActiveRecord.tt to help with sorting based on a string field name but after doing some testing I realized that even though its working as it should be, I am not handling foreign key fields at all (they are just sorting by their value). Even if I need to change how I am accessing the data it is early enough in the project to do that. Just looking for suggestions.

    Read the article

  • Simple File-based Record Storage with Fast Text Searching for Compact Framework and Silverlight

    - by Eric Farr
    I have a single table with lots of records ( 100k) that I need to be able to index and search on several text fields. The easiest searches will have the first part of the string specified (eg, LIKE 'ABC%' in SQL). The tougher searches will need to search for any substring within the text fields (eg, LIKE '%ABC%' in SQL). I need to run on the Compact Framework. SQL Compact is a memory hog and overkill for my one table. Besides, I'd like to be able to run on Silverlight 4 eventually. The file and indexes can be generated on the full .NET Framework and I only need read capability on the Compact Framework. My records are not especially large and can be expressed in fix length format. I'm looking for some existing code or libraries to avoid having to write a file-based BTree implementation from scratch.

    Read the article

  • UITableView via NSFetchedResultsControllerDelegate, select first record by default?

    - by deafgreatdane
    I have a UITableView that gets populated from CoreData via a controller that implements NSFetchedResultsControllerDelegate. How can I have it automatically select the first row (and fire the tableView:didSelectRowAtIndexPath message)? The tableview is used for a variety of predicate queries, so I'm suspicious of solutions that work on the UIViewController lifecycle (viewDidLoad, etc), but I'm new to the platform, so I'm open. I've tried a variety of things, but I'm not sure where in the call stack to put it. I've tried calling cell.selected = true inside tableView:cellForRowAtIndex: method, but that just ends up turning the cell black (and doesn't fire the selected callback method) A tagent question, with all the delegating and core data protocols, does it imply asynchronous data fetch (multiple threads)? Or is the NSFetchedResultsController calling all its related methods in the same thread? Maybe I'm just scared that if it is async, there would be race conditions that would be tough to troubleshoot later.

    Read the article

  • Update "Properties" model when adding a new record in CakePHP

    - by Paul Willy
    Hi, I'm writing an application in CakePHP that, for now, is to be used to make quotes for customers. So Quote is a model. I want to have a separate model/table for something like "Property," which may be used by other models. Each time a user gets to the "Add Quote" action, I basically want to pull a Property called "nextQuoteNumber" or something along those lines, and then automatically increment that property, even if the new Quote isn't saved. So I don't think just using an autoincrement for Quote's id is appropriate here - also, the "quote number" could be different from the row's id. I know this is simple enough to do, but I'm trying to figure out the "proper" CakePHP way of doing it! I'm thinking that I should have a method inside the Property model, say "getProperty($property_name)", which would pull the value to return, and also increment the value... but I'm not sure what the best way of doing that is, or how to invoke this method from the Quotes controller. What should I do? Thanks in advance!

    Read the article

  • Ruby on rails active-record generated SQL on Postgres

    - by jpartogi
    Dear all, Why does Ruby on rails generated more queries in the background on Postgres than MySQL? I haven't tried deploying Rails on production with Postgres yet, but I am just afraid this generated queries would affect the performance. Do you find Rails with Postgres is slower than MySQL, knowing that it produce more query on the background? Or it is relatively the same?

    Read the article

  • update record using ajax

    - by mohsen
    Hi, Can anyone help me regarding update data in the gridview by using AJAX. Once enter the values textboxes and saved into Database, then gridview has to update the new changes. and not by using the ajax updatepanel

    Read the article

  • Rails Active Record Mysql find query HAVING clause

    - by meetraghu28
    Is there a way to use the HAVING clause in some other way without using group by. I am using rails and following is a sample sccenario of the problem that i am facing. In rails you can use the Model.find(:all,:select,conditions,:group) function to get data. In this query i can specify a having clause in the :group param. But what if i dont have a group by clause but want to have a having clause in the result set. Ex: Lets take a query select sum(x) as a,b,c from y where "some_conditions" group by b,c; This query has a sum() aggregation on one of the fields. No if there is nothing to aggregate then my result should be an empty set. But mysql return a NULL row. So this problem can be solved by using select sum(x) as a,b from y where "some_conditions" group by b having a NOT NULL; but what happens in case i dont have a group by clause?? a query like below select sum(x) as a,b from y where "some_conditions"; so how to specify that sum(x) should not be NULL? Any solution that would return an empty set in this case instead of a NULL row will help and also that solution should be doable in rails. We can use subqueries to get this condition working with sumthin like this select * from ((select sum(x) as b FROM y where "some_condition") as subq) where subq.b is not null; but is there a better way to do this thru sql/rails ??

    Read the article

  • Database EAV model, record listing as per search

    - by Shyam Sunder Verma
    I am building a dynamic application. I have three tables : ( EAV model style) 1: Items ( ItemId, ItemName) 2: Fields (FieldId, FieldName) 3: Field Values ( ItemID, FieldId, Value) Can you tell me how to write SINGLE query to get starting 20 records from ALL items where FieldId=4 is equal to TRUE. Expected Result : Columns = ItemID | Name | Field1 | Field2 | Field3 Each Row= ItemId | ItemName| Value1 | Value2 | Value3 Important concerns : 1: Number of fields per item are not known 2: I need one to write ONE query. 3: Query will be running on 100K records, so performance is concern. 4: I am using MySQL 5.0, so need solution for MYSQL Should I denormalize the tables if above query is not possible at all ? Any advice ?

    Read the article

  • Pulling record from mySQL database only working for userid and not email

    - by user2908467
    This function works because I search by userid: private void showList_Click(object sender, EventArgs e) { int id = 0; for (int i = 0; i <= sqlClient.Count("UserList"); i++) { Dictionary<string, string> dik = sqlClient.Select("UserList", "userid = " + id); var lines = dik.Select(kv => kv.Key + ": " + kv.Value.ToString()); userList.AppendText(string.Join(Environment.NewLine, lines)); userList.AppendText(Environment.NewLine); userList.AppendText("--------------------------------------"); id++; } } This function does not work because I search by email: private void login_Click(object sender, EventArgs e) { string email = lemail.Text; Dictionary<string, string> dik = sqlClient.Select("UserList", "firstname = " + email); var lines = dik.Select(kv => kv.Key + ": " + kv.Value.ToString()); logged.AppendText(string.Join(Environment.NewLine, lines)); } This is the error message I receive when I click on the login button: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@aol.com' at line 1 The email I searched for in the database was "[email protected]" without quotes. I'm lead to believe by the error message the @ sign is causing conflict as I know it is a special character but I am having a hard time figuring out what phrase to search for to help me. Also, here is the function that is being called: public Dictionary<string, string> Select(string table, string WHERE) { //This methods selects from the database, it retrieves data from it. //You must make a dictionary to use this since it both saves the column //and the value. i.e. "age" and "33" so you can easily search for values. //Example: SELECT * FROM names WHERE name='John Smith' // This example would retrieve all data about the entry with the name "John Smith" //Code = Dictionary<string, string> myDictionary = Select("names", "name='John Smith'"); //This code creates a dictionary and fills it with info from the database. string query = "SELECT * FROM " + table + " WHERE " + WHERE + ""; Dictionary<string, string> selectResult = new Dictionary<string, string>(); if (this.Open()) { MySqlCommand cmd = new MySqlCommand(query, conn); MySqlDataReader dataReader = cmd.ExecuteReader(); try { while (dataReader.Read()) { for (int i = 0; i < dataReader.FieldCount; i++) { selectResult.Add(dataReader.GetName(i).ToString(), dataReader.GetValue(i).ToString()); } } dataReader.Close(); } catch { } this.Close(); return selectResult; } else { return selectResult; } } My database table is called "UserList" The fields in order are as follows: userid, email, password, lastname, firstname Any help would be greatly appreciated. This site is amazing!

    Read the article

  • Nhibernate Left Outer Join Return First Record of the Join

    - by Touch
    I have the following mappings of which Im trying to bring back 0 - 1 Media Id associated with a Product using a left join (I havnt included my attempt as it confuses the situation) ICriteria productCriteria = Session.CreateCriteria(typeof(Product)); productCriteria .CreateAlias("ProductCategories", "pc", JoinType.InnerJoin) .CreateAlias("pc.ParentCategory", "category") .CreateAlias("category.ParentCategory", "group") .Add(Restrictions.Eq("group.Id", 333)) .SetProjection( Projections.Distinct( Projections.ProjectionList() .Add(Projections.Alias(Projections.Property("Id"), "Id")) .Add(Projections.Alias(Projections.Property("Title"), "Title")) .Add(Projections.Alias(Projections.Property("Price"), "Price")) .Add(Projections.Alias(Projections.Property("media.Id"), "SearchResultMediaId")) // I NEED THIS ) ) .SetResultTransformer(Transformers.AliasToBean<Product>()); IList<Product> products = productCriteria .SetFirstResult(0) .SetMaxResults(10) .List<Product>(); I need the query to populate the SearchResultMediaId with Media.Id, I only want to bring back the first Media in a left outer join, as this is 1 to many association between Product and Media Product is mapped to Media in the following way mapping.HasManyToMany<Media>(x => x.Medias) .Table("ProductMedias") .ParentKeyColumn("ProductId") .ChildKeyColumn("MediaId") .Cascade.AllDeleteOrphan() .LazyLoad() .AsBag(); Any Help would be fantastic.

    Read the article

  • Active record NEW causing a warning

    - by Jon
    I got this snippet of controller code from Railscast 193, functionally its all working, but i am getting a warning message. http://railscasts.com/episodes/193-tableless-model @search = Search.new(:text => params[:search]) getting warning: /Users/Server/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:13: warning: multiple values for a block parameter (0 for 1) from /Users/Server/.gem/ruby/1.8/gems/activerecord-2.3.4/lib/active_record/named_scope.rb:92 Any ideas why i am getting the warning? thanks

    Read the article

  • Auto complete from database using CodeIgniter (Active Record)

    - by Ralph David Abernathy
    I have a form on my website in which one is able to submit a cat. The form contains inputs such as "Name" and "Gender", but I am just trying to get the auto completion to work with the "Name" field. Here is what my jquery looks like : $(document).ready(function() { $( "#tags" ).autocomplete({ source: '/Anish/auto_cat' }); }); Here is what my model looks like: public function auto_cat($search_term) { $this->db->like('name', $search_term); $response = $this->db->get('anish_cats')->result_array(); // var_dump($response);die; return $response; } } Here is my controller: public function auto_cat(){ $search_term = $this->input->get('term'); $cats = $this->Anish_m->auto_cat($search_term); } And here is my view: <head> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css" /> </head> <h1>Anish's Page</h1> <form action="/Anish/create" method="POST"> <div class="ui-widget"> <label for="tags">Name</label><input id="tags" type="text" name="name"> </div> <div> <label>Age</label><input type="text" name="age"> </div> <div> <label>Gender</label><input type="text" name="gender"> </div> <div> <label>Species</label><input type="text" name="species"> </div> <div> <label>Eye Color</label><input type="text" name="eye_color"> </div> <div> <label>Color</label><input type="text" name="color"> </div> <div> <label>Description</label><input type="text" name="description"> </div> <div> <label>marital status</label><input type="text" name="marital_status"> </div> <br> <button type="submit" class="btn btn-block btn-primary span1">Add cat</button> </form> <br/><br/><br/><br/> <table class="table table-striped table-bordered table-hover"> <thead> <tr> <th>Name</th> <th>Gender</th> <th>Age</th> <th>Species</th> <th>Eye Color</th> <th>Color</th> <th>Description</th> <th>Marital Status</th> <th>Edit</th> <th>Delete</th> </tr> </thead> <tbody> <?php foreach ($cats as $cat):?> <tr> <td> <?php echo ($cat['name']);?><br/> </td> <td> <?php echo ($cat['gender']);?><br/> </td> <td> <?php echo ($cat['age']);?><br/> </td> <td> <?php echo ($cat['species']);?><br/> </td> <td> <?php echo ($cat['eye_color']);?><br/> </td> <td> <?php echo ($cat['color']);?><br/> </td> <td> <?php echo ($cat['description']);?><br/> </td> <td> <?php echo ($cat['marital_status']);?><br/> </td> <td> <form action="/Anish/edit" method="post"> <input type="hidden" value="<?php echo ($cat['id']);?>" name="Anish_id_edit"> <button class="btn btn-block btn-info">Edit</button> </form> </td> <td> <form action="/Anish/delete" method="post"> <input type="hidden" value="<?php echo ($cat['id']);?>" name="Anish_id"> <button class="btn btn-block btn-danger">Delete</button> </form> </td> </tr> <?php endforeach;?> </tbody> </table> I am stuck. In my console, I am able to see this output when I type the letter 'a' if I uncomment the var_dump in my model: array(4) { [0]=> array(9) { ["id"]=> string(2) "13" ["name"]=> string(5) "Anish" ["gender"]=> string(4) "Male" ["age"]=> string(2) "20" ["species"]=> string(3) "Cat" ["eye_color"]=> string(5) "Brown" ["color"]=> string(5) "Black" ["description"]=> string(7) "Awesome" ["marital_status"]=> string(1) "0" } [1]=> array(9) { ["id"]=> string(2) "16" ["name"]=> string(5) "Anish" ["gender"]=> string(2) "fe" ["age"]=> string(2) "23" ["species"]=> string(2) "fe" ["eye_color"]=> string(2) "fe" ["color"]=> string(2) "fe" ["description"]=> string(2) "fe" ["marital_status"]=> string(1) "1" } [2]=> array(9) { ["id"]=> string(2) "17" ["name"]=> string(1) "a" ["gender"]=> string(1) "a" ["age"]=> string(1) "4" ["species"]=> string(1) "a" ["eye_color"]=> string(1) "a" ["color"]=> string(1) "a" ["description"]=> string(1) "a" ["marital_status"]=> string(1) "0" } [3]=> array(9) { ["id"]=> string(2) "18" ["name"]=> string(4) "Matt" ["gender"]=> string(6) "Female" ["age"]=> string(2) "80" ["species"]=> string(6) "ferret" ["eye_color"]=> string(4) "blue" ["color"]=> string(4) "pink" ["description"]=> string(5) "Chill" ["marital_status"]=> string(1) "0" } }

    Read the article

  • Is it possible to open and edit 2 or more RecordStores at the same time in j2me?

    - by me123
    Hi, I was wondering if it is possible in j2me to have 2 or more recordStores open at the same time. I basically want to be able to add/remove records from 2 different recordStores in the same execution of the code. Is this possible? If so, how would you do it? At the top of the class, you do something like 'private RecordStore rs;' would you need to have two instances of this to make it work or could you do it with the one declaration? Thanks in advance.

    Read the article

  • retrivenewly inserted record ID with Linq2SQL

    - by devmania
    hi, i am using the following private BlogDataContext db = new BlogDataContext (); article.Created = DateTime.UtcNow; article.Modified = DateTime.UtcNow; db.Articles.InsertOnSubmit(article); db.SubmitChanges( ); int id = article.Id; i am wondering is this save, i mean will it give me the Id of the article user inserted or will there be case of concurrences if another user update the article in fraction of second of second after this user ? thanks in advanced.

    Read the article

  • checkbox update the record using jquery?

    - by python
    <? include("connect.php"); $sql="select * from sampledb"; $res=mysql_query($sql) or die("query failed"); ?> <script type="text/javascript" src="scripts/jquery.js"></script> <script type="text/javascript"> function updateCheckVal() { var valcheck = []; $('#checkbox :checked').each(function() { valcheck.push($(this).val()); }); $('#store_checkbox').val(valcheck) } $(function() { $('#checkbox input').click(updateCheckVal); updateCheckVal(); }); $(function(){ $("a.modify").click(function(){ var val = []; $(':checkbox:checked').each(function(i){ val[i] = $(this).val(); }); $("#deleted_id").val(val); page=$(this).attr("href"); $("#Formcontent").html("loading...").load(page); return false; }); }); </script <form name=""> <table width="100%" border="1" cellpadding="1" cellspacing="1"> <thead> <tr bgcolor="#CCCCCC"> <th></th> <th>ID</th> <th>Fullname</th> </tr> </thead> <tbody> <? while($row=mysql_fetch_assoc($res)){?> <tr> <td id="checkbox"><input type="checkbox" name="chk[]" class="chk" value=<?php echo $row["student_id"];?> ></td> <td><?php echo $row["id"];?></td> <td><?php echo $row["fullname"];?></td> </tr> <? }?> </tbody> </table> <input type="hidden" name="store_checkbox" id="store_checkbox" value=""> <a href="formstudent.php?action=update&id=<?php echo $_POST["store_checkbox"]; ?>" class="modify">modify</a> I want to pass the checkbox value that is checked in something like this: example :formstudent.php?action=update&id=1, I am doing here is pass like this but does not work. <a href="formstudent.php?action=update&id=<?php echo $_POST["store_checkbox"]; ?>" Anybody know how to do this?

    Read the article

  • Active record taking Date.today as yesterday

    - by Mongus Pong
    I have a strange one.. I am doing something like : tip = find (:first, :conditions => ["last_shown = ? or last_shown is null", Date.today]) And then a little later on I do : tip.last_shown = Date.today tip.save When I look at output of these queries, ActiveRecord is doing the first query with todays date as I would expect. However, the send query, ActiveRecord is setting the last_shown date to be yesterdays date. Why on earth would it do this? I have config.time_zone = 'UTC' in my environment.rb. I can use Time.now.utc.to_date instead of Date.today but it makes no difference.

    Read the article

  • Getting random record from database with group by

    - by Saif Bechan
    Hello i have a question on picking random entries from a database. I have 4 tables, products, bids and autobids, and users. Products ------- id 20,21,22,23,24(prime_key) price........... etc........... users ------- id(prim_key) name user1,user2,user3 etc bids ------- product_id user_id created autobids -------- user_id product_id Now a multiple users can have an autobid on an product. So for the next bidder I want to select a random user from the autobid table example of the query in language: for each product in the autobid table I want a random user, which is not the last bidder. On product 20 has user1,user2,user3 an autobidding. On product 21 has user1,user2,user3 an autobidding Then I want a resultset that looks for example like this 20 – user2 21 – user3 Just a random user. I tried miximg the GOUP BY (product_id) and making it RAND(), but I just can't get the right values from it. Now I am getting a random user, but all the values that go with it don't match. Can someone please help me construct this query, I am using php and mysql

    Read the article

  • launch an app to record keep with greasemonkey

    - by acidzombie24
    I have my greasemonkey script scanning every page i visit for a specific string. I would like to recordkeep the variations of the string in a sqlite db. I'll have another app process this db everyonce in a while. What i dont know is HOW do i store the data into the sqlite db? i was thinking i can launch an executable automatically if the string was found but i dont know how to do that through javascript. Another alternative i thought was have a socket listen on a certain port and have some js magic but i couldnt think of a silent way to send data like that.

    Read the article

  • Convert date to string upon saving a doctrine record

    - by takteek
    Hi, I'm trying to migrate one of my PHP projects to Doctrine. I've never used it before so there are a few things I don't understand. In my current code, I have a class similar to this: class ScheduleItem { private Date start; //A PEAR Date object. private Date end; public function getStart() { return $this-start; } public function setStart($val) { $this-start = $val; } public function getEnd() { return $this-end; } public function setEnd($val) { $this-end= $val; } } I have a ScheduleItemDAO class with methods like save(), getByID(), etc. When loading from and saving to the database, the DAO class converts the Date objects to and from strings so they can be stored in a timestamp field. In my attempt to move to Doctrine, I created a new class like this: class ScheduleItem extends Doctrine_Record { public function setTableDefinition() { $this-hasColumn('start', 'timestamp'); $this-hasColumn('end', 'timestamp'); } } I had hoped I would be able to use Date objects for the start and end times, and have them converted to strings when they are saved to the database. How can I accomplish this?

    Read the article

  • SQL query to get latest record for all distinct items in a table

    - by David Buckley
    I have a table of all sales defined like: mysql> describe saledata; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | SaleDate | datetime | NO | | NULL | | | StoreID | bigint(20) unsigned | NO | | NULL | | | Quantity | int(10) unsigned | NO | | NULL | | | Price | decimal(19,4) | NO | | NULL | | | ItemID | bigint(20) unsigned | NO | | NULL | | +-------------------+---------------------+------+-----+---------+-------+ I need to get the last sale price for all items (as the price may change). I know I can run a query like: SELECT price FROM saledata WHERE itemID = 1234 AND storeID = 111 ORDER BY saledate DESC LIMIT 1 However, I want to be able to get the last sale price for all items (the ItemIDs are stored in a separate item table) and insert them into a separate table. How can I get this data? I've tried queries like this: SELECT storeID, itemID, price FROM saledata WHERE itemID IN (SELECT itemID from itemmap) ORDER BY saledate DESC LIMIT 1 and then wrap that into an insert, but it's not getting the proper data. Is there one query I can run to get the last price for each item and insert that into a table defined like: mysql> describe lastsale; +-------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+---------------------+------+-----+---------+-------+ | StoreID | bigint(20) unsigned | NO | | NULL | | | Price | decimal(19,4) | NO | | NULL | | | ItemID | bigint(20) unsigned | NO | | NULL | | +-------------------+---------------------+------+-----+---------+-------+

    Read the article

  • active record relations – who needs it?

    - by M2_
    Well, I`m confused about rails queries. For example: Affiche belongs_to :place Place has_many :affiches We can do this now: @affiches = Affiche.all( :joins => :place ) or @affiches = Affiche.all( :include => :place ) and we will get a lot of extra SELECTs, if there are many affiches: Place Load (0.2ms) SELECT "places".* FROM "places" WHERE "places"."id" = 3 LIMIT 1 Place Load (0.3ms) SELECT "places".* FROM "places" WHERE "places"."id" = 3 LIMIT 1 Place Load (0.8ms) SELECT "places".* FROM "places" WHERE "places"."id" = 444 LIMIT 1 Place Load (1.0ms) SELECT "places".* FROM "places" WHERE "places"."id" = 222 LIMIT 1 ...and so on... And (sic!) with :joins used every SELECT is doubled! Technically we cloud just write like this: @affiches = Affiche.all( ) and the result is totally the same! (Because we have relations declared). The wayout of keeping all data in one query is removing the relations and writing a big string with "LEFT OUTER JOIN", but still there is a problem of grouping data in multy-dimentional array and a problem of similar column names, such as id. What is done wrong? Or what am I doing wrong? UPDATE: Well, i have that string Place Load (2.5ms) SELECT "places".* FROM "places" WHERE ("places"."id" IN (3,444,222,57,663,32,154,20)) and a list of selects one by one id. Strange, but I get these separate selects when I`m doing this in each scope: <%= link_to a.place.name, **a.place**( :id => a.place.friendly_id ) %> the marked a.place is the spot, that produces these extra queries.

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >