artacus
-
Posts
737 -
Joined
-
Last visited
Never
Posts posted by artacus
-
-
I don't understand how sort plays into this. You didn't provide enough info. But based on what you gave
SELECT c.id, c.sort_id, MAX(log.datetime) FROM clothes AS c JOIN log ON c.id = log.clothes_id GROUP BY c.sort_id
-
Because the way records are entered into the db creates a pseudo chronological order by.
-
Its pretty complicated stuff. So I'd suggest going the route I just showed you if you can.
-
Any Python coders here can appreciate the utility of an interactive shell. A tool that I use regularly is PHP Interactive, a web tool that tries to mimic that functionality. It's especially nice when working w/ php freaks because I can quickly test a piece of code, w/o having to open an editor, save a file, test it in a web page.
http://www.hping.org/phpinteractive/
For writing SQL, my favorite tool is Aqua Data Studio. They make you license the product now, but the previous version was free for personal use. The older version is perfectly functional and you can find it here:
http://download.aquafold.com/download/v4.7.2/
For Javascript/AJAX the FF extension Firebug is invaluable.
So what tools have you found that make your life easier?
-
So fix your program.
-
If you want the number to be unique, you are going to have to store the previously used numbers somewhere.
Not really. You could use some bastardization of the timestamp to get a unique id.
-
Yes, it probably will.
-
is there a reel reason to use this style of programming?
I use it often for little things like this:
$css = ($i++ % 2) ? 'class="odd"' : 'class="even"';
-
I've never seen that before. I don't think it works.
I've tried it and it always evaluates to $d.
If it does work, its not at all clear what it is doing.
-
1) easier to read if you use between and you need to quote your dates,
2) don't store each $bank in its own table, store them all in 1 table with a bank field.
3) Can't use HAVING unless there is a group by clause,
SELECT * FROM banks WHERE bank_name = '$bank' AND username = '$username' AND date_stamp BETWEEN '$to' AND '$from' ORDER BY $order DESC
-
SELECT tabA.*
FROM tabA
LEFT JOIN tabB ON tabA.id = tabB.a_id
WHERE tabB.a_id IS NULL
-
You have phpmyadmin or some other tool right? Just look at the structure of your tables, it will tell you what is indexed.
-
umask only works when a file is being created. chmod works after a file is created.
-
It just sets the default (read, write, execute) permissions when a file or directory is created on a unix-like system.
-
bar.yada and bar.bla are required.
No indexes are required per say.
Here foo.id and bar.id are both pk's so they are already indexed. (should be)
foo.bar_id is a fk so you definitely SHOULD index it.
bar.bla would be indexed if it is being searched regularly
bar.yada I wouldn't index.
-
Well the queries for going much deeper than 3 levels gets unruly. So then you switch to the nested tree approach.
There was a great tutorial for doing this in PHP at phpriot.com. The link isn't working for me at the moment. Maybe the server is just having problems...
http://www.phpriot.com/d/articles/php/application-design/nested-trees-2/index.html
-
My tables would probably look something like this:
- categories (id, parent_id, description, sort_order)
- items (id, cat_id, description, size_id, material_id, color_id, ...)
- sizes
- inventory
Using that approach you can comfortably nest categories 3 levels deep. (Shirts->Dress->Long Sleeve). If you feel you need to go more than 3 levels deep, then I'd suggest a different approach. But I kinda doubt you'll need to.
-
-
1) No
2) You have to be smart about your indexing. Indexing will slow your inserts and updates, take up more space but improve your lookups. It is especially important that you index foreign keys, columns you will be joining tables on, and columns you will be doing a lot of searching or filtering on.
-
Using the Insert tab.
-
echo out $xmlstr and be sure you are getting data back.
-
mysql_query only gives you a result set. You need to use mysql_fetch_assoc() or something similar to get the info out of that result set.
Conversely, you could just write it into 1 query.
INSERT INTO enrollment (UID, CID) SELECT UID, '$course' FROM users WHERE username = '$username'
-
Do you have data in there already that exceeds 255 characters?
-
ID IN
in MySQL Help
It WILL update only 4 records. But there is no guarantee that it will be the 4 that you expect. You should get 1 - 4 using an autoinc id. But if you were using something else (last name), it would update the first 4 that it came across and not in A-Z order. You are better off specifying exactly what you want to update instead of relying on LIMIT
Selecting the group-wise maximum
in MySQL Help
Posted
Select your MAX(idUser) in a subquery