Jump to content

vinny42

Members
  • Posts

    411
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by vinny42

  1. It's certainly true that today's programmers want objects for everything, regardless of wether it serves a purpose.
  2. Also, don't use empty(), because empty() will also say that a var is empty if it contains the number zero, which is a very interesting bug to have for example when your form asks for "how many cars do you own" and complains that you are not allowed to have zero cars. Generally speaking: check variables for the content that you *do* want, not for the content you don't want, because you don't know what you don't want, that's why you don't want it. :-) For example, "hello" is not empty, but it's not a date either. 2013-02-31 is a date, but not a valid one. Lots of tutorials exist to help you validate your strings properly, it's not difficult and saves you hours of bugtracking.
  3. You mean to say that you have built an application for registering course attendance and you never once used a join in the entire application? :-) You can, but then you'd have to make the combination of name+date unique, because that will be your primary key. Personally I'd run thought the rules of normalization and put the database in 3d normal form.
  4. This sounds very much like a school assignment, am I right? :-)
  5. I meant that it would give a series of gaps, saving the trouble of having to scan the dates that don't have gaps. Let the database do what it's good at. In PostgreSQL ofcourse you'd use generate_series() to "fill the gaps" and get a list of dates straight from the database.
  6. Or do a self-join to get the full set of 'dates that have no match for the day before' at once. :-)
  7. Will that allow you to edit the excell file or does it always require that you convert it to google0-sheets (which would be a showstopper for me personally, I don't know about the TS of course) And how seamlessly can you integrate google-docs with you won website, can it use ACL from a remote site or do you have to give all your emplyees a google account (another definate showstopper)
  8. Why do you use MongoDB for something that is not document-oriented? Anyway ,exact mathces are always going to take milliseconds because it's just a comparison of two indexes. I'd be more interested in knowing how Mongo deals with partial matches.
  9. I'd move this to a database because they can use indexes to find matches, where PHP cannot (unless you write an indexing routine, which would be interesting but a waste of time because databases already do that). if you use a proper database like PostgreSQL you can use trigram indexes to seriously speedup substring searches. This is actually an interesting issue from a performance point of view.
  10. You can', and you don't have to. When you do a require on a file (you are not using a URL here) then the code of the script you are "requiring" becomes part of the script that you do the require in. So, all variables, all code, everything is already available. This works: index.php: <?php $foo = "bar"; require_once("foopy.php"); ?> foopy.php: <?php echo $foo; ?> The parameters that you use are only required when "require" load a URL, which you should *never* do unless you have absolute control over the URL and remote server. Also, never use a URL to access content on the same server, it's a huge waste or resources.
  11. That seems simple enough, if the player names never contain spaces then this data is simple a CSV file and you can process it like you would any other CSV (including not having to paste it into a textarea, you could just upload a CSV file) if you do use a testarea you can explode() the string on newlines, to get separate lines per player, and split each line around space to get the name and the points. Simply insert the new data into the table and away you go.
  12. First, Don't use getimagesize() for this, it downloads the whole image. Use cURL, which can ask the remote server for only the HTTP headers, which will return status=200 or status=404, etc. Second: ofcourse there is a performance issue if you are going to verify each image every time, which is why you would cache the results in a file somewhere.
  13. It's called a "rolling total" or "cumulative sum, and MySQL can do that for you. Google for instructions like: http://develop-for-fun.blogspot.nl/2012/06/mysql-select-query-make-cumulative-sum.html
  14. You cannot select things that are not in your table. Your application will have to generate the missing dates.
  15. Then use a base62 method in the trigger :-)
  16. Provided that you have a very good reason to do this, you ca do it in the database itself (which is the only place where this should be done anyway) Create a regular INT PK AUTO_INCREMENT column. That will generate the actual ID, leave that in place, it's all you have to guarantee unique values. Use an AFTER INSERT trigger to use the generated ID to create a HEX value, and store that in a separate column. Make your application use that hex value. You'll probably soon find that the HEX values are very difficult to use, but time will tell.
  17. Also, remember that quite a few domains are parked, which means they will resolve but could still be available. Absolutely, although it is sadly also common practice for websites who offer these lookup-tools to register every domainname that comes up as available, so by the time you want to register it, it's suddenly taken and for sale...
  18. fetch_array() will also fill numeric indexes, true, and that would be just as dangerous as using the original expression as an index. A clear, descriptive alias is the best option, you can modifiy the query as much as you want; as long as the data comes out under the correct alias the rest of the code doesn't care.
  19. FYI: you don't absolutely need the alias, it just makes life easier. The data you select becomes available as the expression that you selected, so echo $row['MAX(ID)']; would also work, but it's not pretty, it promotes bugs, it's bad.
  20. Ok, my mistake, it would ofcourse also help to know what the query was.
  21. It seems logical that you'd post the error so when can see it and tell you what the problem could be...
  22. You underestimate me sir, I did read all of it. But what I distilled from it was "I don't see the point of what you are doing" and "you should not use exiting code in school assignment". The first I don't agree with, and the second I think we all know already. Hence my surprise at the verbosity. But I have learned that you write long posts, so I'll compensate my interpretation in future. Anyway, I don't want to start a discussion about this, so consider my remarks as never made.
  23. Nearest neighbour will give you "a" route, not necessarily the shortest route the difference is small but key for your application. You could also make things more interesting by including parameters like which products are the heaviest or most fragile. When I do my shopping I get the refridgerated items and drinks last, and I don't want to have eggs or cookies at the bottom of my shoppingcart.
  24. vinny42

    join rows

    Your second question is not group_concat, because year1 has A and B, but your example shows separate rows for year1, and the first row contains A and C, so there is something special about B, or you haven't thought enough about what you acrually want.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.