w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Web App: Gathering unknown amount of data from user an unknown number of times
Do you mean something like this http://www.labs.mimmin.com/inlineedit/ http://dev.iceburg.net/jquery/tableEditor/example_new.php I found it on google by using 'jquery inline editable table' I know Yii has a nice admin interface specifically fast input, but I sense you wrote the code yourself, transferring to Yii might be a bigger challenge that solving this in a nice way. good luck

Categories : PHP

PyQt4 `QCoreApplication.arguments()` returns 'unknown' when I pass non-ASCII command line arguments
The encoding for QApplication is Latin-1, and you need it to be UTF-8. To get around this, you may manually encode the arguments using .encode('utf-8'), before passing them to QApplication.

Categories : Python

RavenDB Query does not return all records
By default, queries return up to 128 records. Use an explicit Take(n) to get more records.

Categories : C#

RavenDB Query Always Faster Than Load
From what I understand, Load will guarantee to return a result (provided that id exists in the database) whereas Query might not return a result if the indexes haven't yet been updated. You could have a scenario whereby you insert a record, then on the next line try to retrieve that same record using Query and then not get anything back. Load would return a record in this scenario. So I guess the performance degradation you are seeing might be related to the fact that you are querying by index when using Query, whereas Load is hitting the actual data store.

Categories : C#

RavenDB - How do I query on both an object's properties and its children
First, we'll tackle the index, note that child keys are prefixed with Children_ (required by Raven): public class Objekt_ByCodeAndChildren : AbstractIndexCreationTask<Objekt> { public Objekt_ByCodeAndChildren() { Map = objekts => from objekt in objekts from child in objekt.Children select new { objekt.Code, Children_Role = child.Role, Children_Place = child.Place }; } } The query itself: session.Query<Objekt, Objekt_ByCodeAndChildren>() .Where(o => o.Code == "1" && o.Children.Any(c => c.Role == "A" && c.Place =

Categories : C#

RavenDB Query on Inner property serialize with [JsonProperty]
This appears to be a bug in the query provider for DocumentSession.Query<> where it will not honor the Newtonsoft attributes on documents. However if you use the Lucene query provider it will perform as expected: [Test] public void Test() { using (var session = DocumentStore.OpenSession()) { session.Store(new Parent {Inner = new Child {Num = 1}}); session.SaveChanges(); } using (var session = DocumentStore.OpenSession()) { var list = session.Advanced.LuceneQuery<Parent>() .WhereEquals(x => x.Inner.Num, 1) .ToList(); Assert.That(list.Count, Is.EqualTo(1)); } }

Categories : C#

Why my query doesn't return any results from RavenDB?
You should check that the index "Raven/DocumentsByEntityName" is defined for the target database, and that your document has the correct metadata information. The metadata should have a line like this: "Raven-Entity-Name": "CountryRegion" If this does not help, please also post the ravendb version you are using. A fiddler trace might also be helpful.

Categories : C#

Query over a collection of composite keys in RavenDB using C#
There are multiple ways to do this, but the easiest way would be to provide your own document key instead of using the one Raven generates. This is often referred to as using "structured" or "semantic" keys. Here is a good description of the general technique. Simply add a string Id property to your class. You want the document key to reflect the unique key you described, so probably it should have a value such as "reports/2013/Q1/bob" (but you might want a more unique value for user). You can let .Net construct the key for you in the property getter, such as: public class Report { public string Id { get { return string.Format("reports/{0}/Q{1}/{2}", Year, Quarter, User); } } public string User { get; set; } public int Quarter { get; set; } public int

Categories : C#

Query ravendb without defining a model class?
I believe you can use database commands (Query) to accomplish what you are trying, as long as you know the name of the document collection you are trying to get. See here for more information. QueryResult sites = store.DatabaseCommands.Query( "Sites/ByTitle", new IndexQuery { Query = "Title:CN*" }, null);

Categories : C#

Unknown amount of UILabels inside of a UITableViewCell
If you are adding subviews to the cell instead of using the default label, you need to remove the subviews that already have the cell with something like this: while (cell.subviews.count != 0) { [[cell.subviews objectAtIndex:0] removeFromSuperview]; } // And then, add the new subviews Hope it helps.

Categories : IOS

How to make a method taking unknown amount of values?
There is the params-keyword where you can say that you take a not-specified amount of arguments. From MSDN The params keyword lets you specify a method parameter that takes a variable number of arguments. You can send a comma-separated list of arguments of the type specified in the parameter declaration, or an array of arguments of the specified type. You also can send no arguments. No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration. Example: private double TakeAverage(params double[] numbers) { double average = 0.0; if(numbers != null && numbers.Length > 0){ foreach(double d in numbers) average += d; average /= numbers.Length;

Categories : C#

how to pass an unknown amount of values in an IN condition in a SQL function?
The following works, assuming the list is comma separated with no spaces after the commas (and no comma in the codes): WHERE ','+@dynamicAmountOfInputs+',' like '%,'+ITEM_CODE+',%'; Unfortunately, this prevents the use of an index on ITEM_CODE.

Categories : SQL

pass unknown amount of objects using one parameter objective c
You can't - variadic arguments can't be passed down from a function to another. There's a workaround, however: you can parse the arguments yourself, then add them one by one to the alert view: self = [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil]; va_list args; va_start(args, otherButtonTitles); NSString *title; for (title = otherButtonTitles; title != nil; title = va_arg(args, NSString *)) { [self addButtonWithTitle:title]; } va_end(args);

Categories : IOS

Invalid amount of arguments
In properties -> linker -> advanced I set the entry point to 'main'. Don't do that. The entry point needs to be the C Runtime (CRT) entry point, which performs C initialization, obtains the arguments from the operating system, and calls your main function with them. If you don't explicitly tell the linker what the entry point is named, it will automatically pick the right one. The CRT entry point that calls main is named mainCRTStartup (there are other CRT entry points with other names that call the other kinds of main functions supported by Visual C++).

Categories : C++

Dynamic instantiation of unknown amount and names of parameter attributes in Backbone
Why do you want to do all the manipulation in the view. I feel that is a bad practice , as technically speaking View should be completely dumb of the data or Model. If not the model and the view will be tightly coupled. Instead create a model that turns the data into the format you require. There is parse function inside the model which will be called before initialize. So all the calculations can be performed there making the view ignorant.. define([ … ], function( … ){ return Backbone.Model.extend({ initialize: function() { }, parse: function() { // Do your changes here } }); });

Categories : Javascript

Infinite Amount of Command Line Arguments in Python
You don't need to, command line arguments are stored in sys.argv which will give you a list of the command line arguments. You just need to sum over them. from sys import argv print sum(map(int, argv[1:])) # We take a slice from 1: because the 0th argument is the script name. And just do python testScript.py 1 2 3 6 P.S - Command line arguments are stored as strings, so you need to map them to integers to sum over them. *args is used when you need to pass unknown number of values to a function. Consider the following - >>> def testFunc(*args): return sum(args) >>> testFunc(1, 2, 3, 4, 5, 6) 21

Categories : Python

resolveInstanceMethod with unknown number of arguments
You can't use +resolveInstanceMethod: for that, but you can use traditional forwarding. +resolveInstanceMethod: just installs a new instance method on the class using the Objective-C runtime. You don't get to affect how it is called. It will be called just like any other method with the arguments in the registers and on the stack as the caller supplied them. You don't get an opportunity to package or marshal the arguments. If you implement -forwardInvocation: and -methodSignatureForSelector:, then you get an NSInvocation object. That's already a packaging of the arguments (and return value). You can use that as it is or interrogate it to unpack the arguments and repack them how you want.

Categories : Objective C

Python wrap function with unknown arguments
You can use *args and **kwargs: def bar(*args, **kwargs): return foo(*args, **kwargs) args is a list of positional arguments. kwargs is a dictionary of keyword arguments. Note that calling those variables args and kwargs is just a naming convention. * and ** do all the magic for unpacking the arguments. Also see: documentation What do *args and **kwargs mean? *args and **kwargs?

Categories : Python

How to pass a selector with unknown number of arguments to a method in objective C
Instead of passing selectors + parameters, pass blocks of code. Your code seems like a perfect example for a completion block. Example: - (void)someMethodWithCompletionBlock:(void(^)())completionBlock { //do something completionBlock(); } [myObject someMethodWithCompletionBlock:^{ [SupportClass performSelector:selector]; };

Categories : Objective C

Query within another query to count amount of items from another table
Try this: SELECT p.* ,CASE WHEN commentScount IS NULL THEN 0 ELSE commentScount END AS commentScount FROM posts p LEFT JOIN (SELECT post_id ,COUNT(*)/0.5 commentScount FROM comments GROUP BY post_id) AS c ON p.id = c.post_id; See this SQLFiddle

Categories : Mysql

Formatting a decimal value with ToString() to have commas as thousand separators where the amount of decimal places is unknown
Try using Format. double d = 1.234567; String output = d.ToString("#,##0.##"); Also, double d = 123456789.1; string format = d.ToString(). IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator) >=0 ? "#,##0.00" : "#,##0"; Console.WriteLine (d.ToString(format));

Categories : C#

Mysql show Name, SUM(Amount) WHERE Amount is less than 210 AND SUM(Amount) is greater or equal to 210
use HAVING clause to filter up aggregated results like SUM(), etc. SELECT Name, SUM(Amount) FROM tableName WHERE Amount < 210 GROUP BY Name HAVING SUM(Amount) >= 210

Categories : Mysql

query - group by max amount
You need a cumulative sum for this. The idea is then simple; just choose the rows where the cumulative sum is less than or equal to 200. SQL Server 2005 does not have a built-in cumulative sum (SQL Server 2012 does). I tend to use correlated subqueries in this situation: select sender, receiver, amount, count(*) from (select t.*, (select sum(t2.amount) from t t2 where t2.sender = t.sender and t2.receiver = t2.receiver and t2.date <= t.date ) as cumAmount from t ) t where cumAmount <= 200 group by sender, receiver, amount Note: in your example, the amounts are all the same for a given pair. If they are different, then this query will list all the amounts for each pair on di

Categories : SQL

How do I tell PHP to wait for an SQL query only for a certain amount of time?
Since the query is not sensitive, you should cache the results instead of hitting the database each time. PHP provides mysqlnd-qc the (qc is for query cache) which works with APC and friends to cache the results of MySQL queries. The other option is to cache the template instead. Smarty has this included. This means you render the page once, and then only render it after a certain fixed time.

Categories : PHP

Country total amount in PHP from MYSQL Query
It looks like you are possibly mixing up ANSI 89 and 92 syntax in your statement SELECT t.*, gi.cname FROM tasks t LEFT JOIN geoip_all gi on t.ip > gi.iplong_start and t.ip < gi.iplong_end I have changed your where to an on statement. You are able to still add an actual where clause on the bottom of this statement though. You might also do well to have a read of this in depth article I put together on how to get data from multiple tables. It covers off joins, inner and outer, aggregates and a bunch more.

Categories : PHP

query that return only number of rows base on amount
Taken into account the request to order by duedate, and to know how much is 'left' you get something like the following. This query will get you the amount left from the payment in left and the balance after substracting (what's left of) the payment in new_balance. SELECT p.*, IF(balance < @left, 0, balance - @left) AS 'new_balance', @left := IF(balance > @left, 0, @left - balance) AS 'left' FROM ( SELECT * FROM payable WHERE balance > 0 ORDER BY duedate, payableid ) AS p JOIN (SELECT @left := 6000) AS r ON @left > 0 The above query in SQL Fiddle Some notes: As duedate is not unique I've added payableid (which I assume is unique) as well. For consistency's sake the ORDER BY in the subquery for p must be unique. The results returned by the s

Categories : Mysql

Query to get top 5 users by total month sales amount
Are you looking for a query like this? SELECT user_id FROM ( SELECT user_id, SUM(amount) total FROM sales WHERE status = 'S' AND MONTH(date) = MONTH(CURDATE()) AND YEAR(date) = YEAR(CURDATE()) GROUP BY user_id ) q ORDER BY total DESC LIMIT 5 or just SELECT user_id FROM sales WHERE status = 'S' AND MONTH(date) = MONTH(CURDATE()) AND YEAR(date) = YEAR(CURDATE()) GROUP BY user_id ORDER BY SUM(amount) DESC LIMIT 5 Here is SLQFiddle demo Note: using MONTH() and YEAR() functions will prevent MySql from using any index you might have on date column Now your php code might look like this $db = new mysqli('localhost', 'user', 'password', 'dbname'); if ($db->connect_errno) { die('Cannot connect'); // TODO: better error handling } $sql

Categories : Mysql

Limit in db query returns wrong amount for certain values
Well. I had one shop that is closed all day on Saturday (the day I was querying for). I began to wonder if this record was acting as a "ghost" getting included in the query (even though it shouldn't) without actually returning. This would explain why the last record of each query was missing, because the ghost record was knocking it off the list. So I tried making a dummy opening time for this shop. I had it open at 00:01 and stay open for one minute. Suddenly, everything worked! If that isn't already weird enough, I then deleted this dummy record, and it still worked. I'm not accepting my own answer out of hope that someone can explain what on earth happened. At this point, demon possession and witchcraft appear like reasonable explanations.

Categories : Ruby On Rails

Facebook FQL Query only returning a limited amount of objects?
FQL has LIMIT and OFFSET keywords. You can get upto 5000 results at a time but better way to do it is through pagination eg: SELECT username FROM page WHERE CONTAINS("Musician/Band") LIMIT 200 //gets first 200 results SELECT username FROM page WHERE CONTAINS("Musician/Band") LIMIT 200 OFFSET 201 //to get next 200 results and so on.. Also you can use Facebook multiquery to minimize number of queries made.

Categories : Facebook

Mysql query statement to find how many time I am the max amount for a listing
This might be close, not sure exactly how you're relating vehicles together. select user_id, count(*) as num_bids, SUM(is_highest) as max_bids from ( select a.user_id, COALESCE((select MAX(b.amount) < a.amount from bid as b where b.id < a.id and b.veh_id=a.veh_id ), 1) as is_highest from bid as a ) as c group by user_id My understanding is user 30 has 2 max bids (2 first bids on a vehicle). EDIT: If you're just looking for total 1 max bid per vehicle, let me know. That's actually a lot easier than rolling back to see who's bids were max when they came in... EDIT2: Solution for only 1 max counts per vehicle: Seems like this should be simpler for some reason: select user_id, count(*) as num_bids, count(vamt) as num_max from bid left join ( s

Categories : Mysql

How to write a query that will efficiently handle large amount of records?
Without knowing the exact SQL dialect, I'd perform an INNER JOIN: SELECT ProductID, AccountID, ContractID FROM X INNER JOIN MemTable m ON m.ProductID = X.ProductID AND m.AccountID = X.AccountID You now added Java as a tag, so am I right in thinking that the map is within your Java application? If so, it will get tough - you may actually need to query the database a million times. On the other hand you could construct a string containing one single, large SQL statement like that: SELECT * FROM X WHERE ProductID IN (...) AND AccountID IN (...) where your loop just fills in a list of product IDs and account IDs comma separated. Then you issue that command once. The command should for example look like this, assuming both IDs are numeric: SELECT * FROM X WHERE ProductID IN (1,2,3,4)

Categories : Java

Execute query on "unknown" table
class something { def reallyObscureMethodBecauseYourquestionIsreallyNotClear() { def someResults = anything.where { whateverProperty == 'whatever condition' }.list() render(view:'someOtherView',model:[crazyunspecificModel:someResults]) } } class anything{ } Seriously, you could have put a little more effort into framing your question, this is a lazy question from where I am standing. UPDATE So this is probably your first try at anything close to the JVM, right? If you want to use a class you need to import it, if your controller is in a different package than your external class. If your users class (by the way, convention recommends to use Capitalized Names for Classes, and uncapitalized names for variables) is in package com.exampl

Categories : Grails

Oracle SQL Query:Find out which year total sales amount is maximum
Following select should do what you need (untested, do not have Oracle at home): select year, total from ( select year, sum(sales_amount) total from sales group by year ) where total = (select max(total_amount) from ( select year, sum(sales_amount) total_amount from sales group by year )) Take in account, though, that it might give you different years in each execution if two of them have exactly the same total amount. You might want to include some more conditions to avoid this.

Categories : SQL

Mysql. Deduct SUM(d.Amount) from SUM(c.Amount) and group by (depending on) values in other column
SELECT TransactionPartnerName, SUM(if(CAST(DebitAccount AS UNSIGNED) IN (?), -Amount, Amount)) FROM 2_1_journal DATA WHERE (CAST(DebitAccount AS UNSIGNED) IN (?) OR CAST(CreditAccount AS UNSIGNED) IN (?)) GROUP BY TransactionPartnerName Try this Edit : Removed inner query

Categories : Mysql

Progress bar for unknown Rally query size
The best way to determine if a Rally App is partially complete would be to determine what percentage of pages Rally had returned. Since we limit the size to 200 objects per page you can get a decent estimate of your progress for long running queries based upon those pages.

Categories : Javascript

Mysql Insert Query, unknown error
You are not putting quotes around the strings you are inserting: $sql2 = "INSERT into `djs` (`name`,`pic`,`about`) VALUES ('".$row['dj_name']."','".$row['dj_picture']."','".$row['dj_intro']."')";

Categories : PHP

Trouble with converting fixed-amount of for loops to parametrized amount
Ok, instead of stalling there is a solution which will work for ints, a general solution is much harder, note: This will "spiral" out in boxes. public static void main(String... ignored) { caller(10, 7, new Callback<int[]>() { @Override public void on(int[] ints) { System.out.println(Arrays.toString(ints)); } }); } interface Callback<T> { public void on(T t); } public static void caller(int maxSum, int dimensions, Callback<int[]> callback) { int[] ints = new int[dimensions]; for (int t = 0; t < maxSum; t++) { caller(t, 0, ints, callback); } } private static void caller(int sum, int idx, int[] ints, Callback<int[]> callback) { if (idx == ints.length) { callback.on(ints); re

Categories : Java

mysql query error 1054 - unknown column
You can't use columns from a inner select outside it like this. Select r.id instead select r.id from roles r where id = (select role_id from roles_to_user rtu where user_id = 1) BTW that will fail if the inner select returns more than 1 record. Use a join instead select rtu.role_id from roles r inner join roles_to_user rtu on rtu.role_id = r.id where rtu.user_id = 1

Categories : Mysql

PHP MYSQL Couldn't execute query: Unknown column
replace this: $result = mysqli_query($con, "DELETE FROM Tools WHERE PartNumber = {'$_POST['pnumber']'}") or die ("Couldn't execute query: " .mysqli_error($con)); With this: $result = mysqli_query($con, "DELETE FROM Tools WHERE PartNumber = '" . $_POST['pnumber'] ."'") or die ("Couldn't execute query: " .mysqli_error($con)); Notice I did not take care of sql injection above Even better is to use prepare statements that will secure your querys, in your case it will be something like this: $sql= 'DELETE FROM Tools WHERE PartNumber= ?'; $stmt = $con->prepare($sql); $stmt->bind_param('i', $_POST['pnumber']); $stmt->execute();

Categories : PHP

Mongo query inside Hashmap with unknown hash key
If fields were an array and your key a part of the sub-document instead: "fields" : [ { "key" : "dc", "label" : "DC", "name" : "dc" }, { "key" : "tc", "label" : "TC", "name" : "tc" } ] In this case, you could simply query for any sub-element inside the array: db.coll.find({"form.fields.label":"TC"}) Not sure how you would integrate that with Spring, but perhaps the idea helps? As far as indexes are concerned, you can index into the array, which gives you a multi-key index. Basically, the index will have a separate entry pointing to the document for each array value.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.