Search Results

Search found 5371 results on 215 pages for 'keys'.

Page 35/215 | < Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >

  • Filtering foreign keys with AJAX in Django admin

    - by cnobile
    I have most of this figured out already. I have AJAX returning the region/state/province when a country is selected. The correct foreign key is saved to the database, however, when the record is viewed afterwards the selected state is not shown in the select nor are any states for the selected country. I understand why this is happening as, the admin view is not aware of the relation between the state and the country. So here is the question. Is there a hook in the admin view that will allow me to load the correct states for the country and set the selected attribute on the option in the select tag? Or how can I override the admin view for any forms that require the country and region/state/province set? I am using jQuery and Djando-1.1. Thanks

    Read the article

  • Advice Please: SQL Server Identity vs Unique Identifier keys when using Entity Framework

    - by c.batt
    I'm in the process of designing a fairly complex system. One of our primary concerns is supporting SQL Server peer-to-peer replication. The idea is to support several geographically separated nodes. A secondary concern has been using a modern ORM in the middle tier. Our first choice has always been Entity Framework, mainly because the developers like to work with it. (They love the LiNQ support.) So here's the problem: With peer-to-peer replication in mind, I settled on using uniqueidentifier with a default value of newsequentialid() for the primary key of every table. This seemed to provide a good balance between avoiding key collisions and reducing index fragmentation. However, it turns out that the current version of Entity Framework has a very strange limitation: if an entity's key column is a uniqueidentifier (GUID) then it cannot be configured to use the default value (newsequentialid()) provided by the database. The application layer must generate the GUID and populate the key value. So here's the debate: abandon Entity Framework and use another ORM: use NHibernate and give up LiNQ support use linq2sql and give up future support (not to mention get bound to SQL Server on DB) abandon GUIDs and go with another PK strategy devise a method to generate sequential GUIDs (COMBs?) at the application layer I'm leaning towards option 1 with linq2sql (my developers really like linq2[stuff]) and 3. That's mainly because I'm somewhat ignorant of alternate key strategies that support the replication scheme we're aiming for while also keeping things sane from a developer's perspective. Any insight or opinion would be greatly appreciated.

    Read the article

  • Unable to relate two MySQL tables (foreign keys)

    - by KPL
    Hello people, Here's my USER table CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(100) NOT NULL, `expiry` varchar(6) NOT NULL, `contact_id` int(11) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(100) NOT NULL, `level` int(3) NOT NULL, `active` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`id`,`email`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; And here's my contact_info table CREATE TABLE IF NOT EXISTS `contact_info` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `email_address` varchar(255) NOT NULL, `company_name` varchar(255) NOT NULL, `license_number` varchar(255) NOT NULL, `phone` varchar(30) NOT NULL, `fax` varchar(30) NOT NULL, `mobile` varchar(30) NOT NULL, `category` varchar(100) NOT NULL, `country` varchar(20) NOT NULL, `state` varchar(20) NOT NULL, `city` varchar(100) NOT NULL, `postcode` varchar(50) NOT NULL, PRIMARY KEY (`id`,`email_address`), ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; The system uses username to login users.I want to modify it in such a way that it uses email for login. But there's no email_address in users table. I have added foreign key - email in user table(which is email_address in contact_info). How should I query database?

    Read the article

  • Database design MySQL using foreign keys

    - by dscher
    I'm having some a little trouble understanding how to handle the database end of a program I'm making. I'm using an ORM in Kohana, but am hoping that a generalized understanding of how to solve this issue will lead me to an answer with the ORM. I'm writing a program for users to manage their stock research information. My tables are basically like so: CREATE TABLE tags( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, tags VARCHAR(30), UNIQUE(tags) ) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE stock_tags( id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, tag_id INT NOT NULL, stock_id INT NOT NULL, FOREIGN KEY (tag_id) REFERENCES tags(id), FOREIGN KEY(stock_id) REFERENCES stocks(id) ON DELETE CASCADE ) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE notes( id INT AUTO_INCREMENT NOT NULL, stock_id INT NOT NULL, notes TEXT NOT NULL, FOREIGN KEY (stock_id) REFERENCES stocks(id) ON DELETE CASCADE, PRIMARY KEY(id) ) ENGINE=INNODB DEFAULT CHARSET=utf8; CREATE TABLE links( id INT AUTO_INCREMENT NOT NULL, stock_id INT NOT NULL, links VARCHAR(2083) NOT NULL, FOREIGN KEY (stock_id) REFERENCES stocks(id) ON DELETE CASCADE, PRIMARY KEY(id) ) ENGINE=INNODB DEFAULT CHARSET=utf8; How would I get all the attributes of a single stock, including its links, notes, and tags? Do I have to add links, notes, and tags columns to the stocks table and then how do you call it? I know this differs using an ORM and I'd assume that I can use join tables in SQL. Thanks for any help, this will really help me understand the issue a lot better.

    Read the article

  • Strategies for generating Zend Cache Keys

    - by emeraldjava
    ATM i'm manually generating a cache key based on the method name and parameters, then follow to the normal cache pattern. This is all done in the Controller and i'm calling a model class that 'extends Zend_Db_Table_Abstract'. public function indexAction() { $cache = Zend_Registry::get('cache'); $individualleaguekey = sprintf("getIndividualLeague_%d_%s",$leagueid,$division->code); if(!$leaguetable = $cache->load($individualleaguekey)) { $table = new Model_DbTable_Raceresult(); $leaguetable = $table->getIndividualLeague($leagueid,$division,$races); $cache->save($leaguetable, $individualleaguekey); } $this->view->leaguetable = $leaguetable; .... I want to avoid the duplication of parameters to the cache creation method and also to the model method, so i'm thinking of moving the caching logic away from my controller class and into model class packaged in './model/DbTable', but this seems incorrect since the DB model should only handle SQL operations. Any suggestions on how i can implement a clean patterned solution?

    Read the article

  • Sort array with multiple keys

    - by Vincent
    All, I have the following array in array format. The JSON format is shown just for user-friendliness. How can I sort the array ascending with the key "name" in php? "food": [ { "id": 1, "name": "dessert" }, { "id": 2, "name": "maincourse" }, { "id": 3, "name": "entrees" }, { "id": 4, "name": "appetizers" } ]

    Read the article

  • Need sorted dictionary designed to find values with keys less or greater than search value

    - by Captain Comic
    Hi I need to have objects sorted by price (decimal) value for fast access. I need to be able to find all objects with price more then A or less than B. I was thinkg about SortedList, but it does not provide a way to find ascending or descending enumerator starting from given key value (say give me all objects with price less than $120). Think of a system that accepts items for sell from users and stores them into that collection. Another users want to find items cheaper than $120. Basically what i need is tree-based collection and functionality to find node that is smaller\greater\equal to provided key. Please advice.

    Read the article

  • Showing all rows for keys with more than one row

    - by Leif Neland
    Table kal id integer primary key init char 4 indexed job char4 id init job --+----+------ 1 | aa | job1 2 | aa | job2 3 | bb | job1 4 | cc | job3 5 | cc | job5 I want to show all rows where init has more than one row id init job --+----+------ 1 | aa | job1 2 | aa | job2 4 | cc | job3 5 | cc | job5 I tried select * from kal where init in (select init from kal group by init having count(init)2); Actually, the table has 60000 rows, and the query was count(init)<40, but it takes humongus time, phpmyadmin and my patience runs out. Both select init from kal group by init having count(init)2) and select * from kal where init in ('aa','bb','cc') runs in "no time", less than 0.02 seconds. I've tried different subqueries, but all takes "infinite" time, more than a few minutes; I've actually never let them finish. Leif

    Read the article

  • reversing keys/values - create new instance of HashMap

    - by stck777
    I’ve got an existing instance of HashMap simply called sale (it is Map) I use it to log customers and items history. Is there a way to create a new instance of HashMap, that effectively reverses this usage? i.e will show each item purchased as a unique key and the corresponding value as a String set of the customers that have purchased that product. I suspect there is a simple process using keySet() in some way to iterate over the sales map but I just can’t see how to do this. Any help would be much appreciated.

    Read the article

  • NHibernate - get List<long> representing primary keys?

    - by Nathan
    I have a situation where I definitely don't want to get the whole domain object. Basically, the entity has a primary key of long (.NET)/bigint(sql server 2005). I simply need to pass the primary key to an external system which will access the database directly - and since the list of ids could be large, I don't want to rehydrate the entire domain object just to get the Id. In linq2sql, I could accomplish this with a projection, but I am restricted to NHibernate 1.2.1.4000, which doesn't support Linq. Is there a way to accomplish this using NHibernate 1.2.1.4000? (I am open to using a named-query if that will work)

    Read the article

  • How to save to Django Model that Have Mulitple Foreign Keys Fields

    - by Spikie
    I have Models for business Apps class staff_name(models.Model): TITLE_CHOICES = ( ('Mr', 'Mr'), ('Miss', 'Miss'), ( 'Mrs', 'Mrs'), ( 'chief', 'chief'), ) titlename = models.CharField(max_length=10,choices=TITLE_CHOICES) firstname = models.CharField(max_length=150) surname = models.CharField(max_length=150) date = models.DateTimeField(auto_now=True) class meta: ordering = ["date"] get_latest_by = "date" class inventory_transaction(models.Model): stock_in = models.DecimalField(blank=True, null=True,max_digits=8, decimal_places=2) stock_out = models.DecimalField(blank=True,null=True,max_digits=8, decimal_places=2) Number_container = models.ForeignKey(container_identity) staffs = models.ForeignKey(staff_name) goods_details = models.ForeignKey(departments) balance = models.DecimalField(max_digits=8, decimal_places=2) date = models.DateTimeField(auto_now=True) What i want to accomplish is check if the staff have made entry to the table before if yes add the value for the stock in plus (last) balance field and assign to balance if no just assign stock in value to balance field and save these are my codes These are my codes: try: s = staffname.staffs_set.all().order_by("-date").latest() # staffname is the instant of the class model staff_name e = s.staffs_set.create(stockin=vdataz,balance=s.balance + vdataz ) # e is the instant of the class model inventory_transaction e.save e.staffs.add(s) e.from_container.add(containersno) e.goods_details.add(department) except ObjectDoesNotExist: e = staff_name.objects.create(stockin=vdataz,balance=vdataz ) e.save e.staffs.add(staffname) e.from_container.add(containersno) e.goods_details.add(department) I will really appreciate a solution Thanks I hope it make more sense now. iam on online if you need more explanation just ask in the comment.Thank you for your help

    Read the article

  • Special chars in Amazon S3 keys?

    - by Martin
    Is it possible to have special characters like åäö in the key? If i urlencode the key before storing it works, but i cant really find a way to access the object. If i write åäö in the url i get access denied (like i get if the object is not found). If i urlencode the url i paste in the browser i get "InvalidURICouldn't parse the specified URI". Is there some way to do this?

    Read the article

  • FieldError when annotating over foreign keys

    - by X_9
    I have a models file that looks similar to the following: class WithDate(models.Model): adddedDate = models.DateTimeField(auto_now_add=True) modifiedDate = models.DateTimeField(auto_now=True) class Meta: abstract = True class Match(WithDate): ... class Notify(WithDate): matchId = models.ForeignKey(Match) headline = models.CharField(null=True, blank=True, max_length=10) For each Match I'm trying to get a count of notify records that have a headline. So my call looks like matchObjs = Match.objects.annotate(notifies_made=Count('notify__headline__isnull')) This keeps throwing a FieldError. I've simplified the query down to matchObjs = Match.objects.annotate(notifies_made=Count('notify')) And I still get the same FieldError... I've seen this work in other cases (other documentation, other SO questions like this one) but I can't figure out why I'm getting an error. The specific error that is returned is as follows: Cannot resolve keyword 'notify' into field. Choices are: (all fields from Match model) Does anyone have a clue as to why I can't get this annotation to work across tables? I'm baffled after looking at the other SO question and various Django docs where I've seen this done. Edit: I am using Django 1.1.1

    Read the article

  • MySQL Many to Many with Unique keys and Update/Select if Exists otherwise Insert

    - by Jayrox
    In my goal to have a Many-to-Many relationship in my MySQL database I have arrived at another bridge to build. Current Tables: Users (id, name) Tags (id, name) User_Tags (user_id, tag_id) Here is the goal: I would like to have the ability to take a tag i.e: #fb and insert it into my Tags database which has a unique constraint on name and if the tag exists I would like to return it's id I would like to insert the tag.id and the current user's user.id into User_Tags. I do not have any unique constraints on the User_Tags table because I would like to be able to track the user's most commonly used tags and present them in a list ordered by frequency of use. I am currently developing this project in PHP using prepared statements. Additionally, performance is not currently an issue as my user count is still fairly small, but it is steadily growing and may be an issue in the future.

    Read the article

  • C++ find multiple keys from a std::multimap

    - by sch0ck9
    I have a STL::multimap and I search to populate a std::list with value which key is duplicated. Can I find/insert to a std::list the value of elements for all key where count 1 without counting them one by one? std::multimap<int, std::string> mm ; mm[0] = "a" ; mm[1] = "b" ; mm[0] = "c" ; mm[2] = "j" ; mm[2] = "k" ; std::list<std::string> lst ; lst might contains "a" ,"c","j","k" ; I try this template <class K, class V> class extract_value { private: K last_key_ ; std::list<V> m_list_value ; std::pair<K, V> first_elem ; public: extract_value(const K& k_): last_key_(k_) { } void operator() (std::pair<const K, V> elem) { if (last_key_ == elem.first) { m_list_value.push_back(elem.second) ; } else { // First entry last_key_ = elem.first; first_elem= elem ; } } std::list<V> get_value() { return m_list_value ; } }; ex_ = for_each(mm.begin(),mm.end(), extract_value<int, std::string>(0)) ; std::list<std::string> lst = ex_.get_value() ; I'm not sure that this code compile.

    Read the article

  • Indexes and multi column primary keys

    - by David Jenings
    Went searching and didn't find the answer to this specific noob question. My apologies if I missed it. In a MySQL database I have a table with the following primary key PRIMARY KEY id (invoice, item) In my application I will also frequently be selecting on "item" by itself and less frequently on only "invoice". I'm assuming I would benefit from indexes on these columns. MySQL does not complain when I define the following: INDEX (invoice), INDEX (item), PRIMARY KEY id (invoice, item) But I don't see any evidence (using DESCRIBE -- the only way I know how to look) that separate indexes have been established for these two columns. So the question is, are the columns that make up a primary key automatically indexed individually? Also, is there a better way than DESCRIBE to explore the structure of my table?

    Read the article

  • How do I restrict foreign keys choices to related objects only in django

    - by Jeff Mc
    I have a two way foreign relation similar to the following class Parent(models.Model): name = models.CharField(max_length=255) favoritechild = models.ForeignKey("Child", blank=True, null=True) class Child(models.Model): name = models.CharField(max_length=255) myparent = models.ForeignKey(Parent) How do I restrict the choices for Parent.favoritechild to only children whose parent is itself? I tried class Parent(models.Model): name = models.CharField(max_length=255) favoritechild = models.ForeignKey("Child", blank=True, null=True, limit_choices_to = {"myparent": "self"}) but that causes the admin interface to not list any children.

    Read the article

  • assign keys for combo box in java

    - by adesh kumar
    I want to add a JComboBox in Swing that is simple but I want to assign the values for each items in combo. I have the following code JComboBox jc1= new JComboBox(); jc1.addItem("a"); jc1.addItem("b"); jc1.addItem("c"); Now what I want is that when click on combo box it should return 1, 2 and 3 correspondingly instead of a ,b, c. Is there any way to assign the key values for each items in combo box?

    Read the article

  • Weird behavior of matching array keys after json_decode()

    - by arnorhs
    I've got some very weird behavior in my PHP code. I don't know if this is actually a good SO question, since it almost looks like a bug in PHP. I had this problem in a project of mine and isolated the problem: // json object that will be converted into an array $json = '{"5":"88"}'; $jsonvar = (array) json_decode($json); // notice: Casting to an array // Displaying the array: var_dump($jsonvar); // Testing if the key is there var_dump(isset($jsonvar["5"])); var_dump(isset($jsonvar[5])); That code outputs the following: array(1) { ["5"]=> string(2) "88" } bool(false) bool(false) The big problem: Both of those tests should produce bool(true) - if you create the same array using regular php arrays, this is what you'll see: // Let's create a similar PHP array in a regular manner: $phparr = array("5" => "88"); // Displaying the array: var_dump($phparr); // Testing if the key is there var_dump(isset($phparr["5"])); var_dump(isset($phparr[5])); The output of that: array(1) { [5]=> string(2) "88" } bool(true) bool(true) So this doesn't really make sense. I've tested this on two different installations of PHP/apache. You can copy-paste the code to a php file yourself to test it. It must have something to do with the casting from an object to an array.

    Read the article

  • Custom keys for Google App Engine models (Python)

    - by Cameron
    First off, I'm relatively new to Google App Engine, so I'm probably doing something silly. Say I've got a model Foo: class Foo(db.Model): name = db.StringProperty() I want to use name as a unique key for every Foo object. How is this done? When I want to get a specific Foo object, I currently query the datastore for all Foo objects with the target unique name, but queries are slow (plus it's a pain to ensure that name is unique when each new Foo is created). There's got to be a better way to do this! Thanks.

    Read the article

< Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >