Jump to content

wickning1

Members
  • Posts

    405
  • Joined

  • Last visited

    Never

Everything posted by wickning1

  1. I was thinking something like this (Perl). [code]#!/usr/bin/perl if (length(`cat /usr/home/master/usr/home/somefolder/somedatadump.psv`) > 0) { print `/usr/home/master/usr/local/bin/mysql -u uname -p pword < /usr/home/master/command/command.sql`; } [/code]
  2. Your code would work except that you misspelled $row_property as $row_proptery. I do agree with fenway though, the do { } while (); structure you are using is unnecessary and cumbersome.
  3. I've never done any SQL scripting, so hopefully someone else can provide a better answer. However, you could always wrap it with another scripting engine like BASH or Perl, which probably provide a lot more flexibility. Then you just use your cron job to run the (for example) Perl script.
  4. Sounds like a simple error, but there are millions of ways to mess up. Post some code and we'll see if we can find any problems.
  5. I'm not exactly sure what you're asking.. are letters mixed with symbols and numbers in the same row and column, or is this a column where each row is either alphabetic or not alphabetic?
  6. khendar's query will work, but I highly encourage the more formal syntax, as it helps you understand the nature of a join and what a join condition is. Also I used a LEFT JOIN so that if a player has not yet been assigned a position, he shows up in the list with a blank position. The other way, the player would be completely omitted. [code]SELECT p.player_id, s.position_abbv FROM players p LEFT JOIN positions s ON p.position_id = s.position_id WHERE anythingelseyouwant[/code]
  7. He forgot to bring it outside the quotes. Replace this line: [code]$query = 'DELETE FROM virtualdb_bu2 WHERE mlsnum IN (' . $id_list . ')';[/code]
  8. Assuming timestamp is stored in one of the date formats, this should work: [code]select ip_src, ip_dst, sport, dport, timestamp, sig_name from acid_event where timestamp between '2006-01-22' and CURDATE()[/code]
  9. You're already heading in the right direction. It can become as complex as you allow it to become. Just be sure to stop somewhere so your software doesn't become vaporware. :)
  10. I'm not sure that MATCH AGAINST will work with commas, but it should. But in order for it to work, you must put a FULLTEXT index on the column you wish to search. If you don't, MySQL returns a syntax error. Note that it will drop certain trivial words from the index unless you tell it not to, and may not index numbers, I'm not sure. In those cases the result would (incorrectly) come back empty. You can use a REGEXP search to make sure it doesn't do anything tricky, but it will be slow.
  11. The easiest way for a database to balloon up to unmanageable size is with a bad database design that involves duplicate and redundant data. As long as you avoid that, you will be fine going with the simplest solution. For instance, are these child objects ever linked to more than one parent? When that happens, do you have 2 rows in the child table for the same object, just because it has two parents? That would be bad. It sounds like you have a pretty good handle on indexing, so you should be ok there. Just be sure to watch all your queries closely. Every time you write one, time it and make sure it only takes a few tens of milliseconds. If it takes a lot longer than your other queries, you may need to rethink it or add indexes.
  12. You can use this: [code]preg_match('/\d*(\.\d+)?/', $text_string, $match_array); $number = $match_array[0];[/code] That will match '0.1', '3', and '.1'.
  13. You just have to give it two different aliases. [code]SELECT i.name, o.name FROM device i INNER JOIN device_relation r ON r.input_device_id=i.device_id INNER JOIN device o ON r.output_device_id=o.device_id[/code]
  14. "foreach($_arr[$i] as $key => $row) {" The error you're getting happens when $_arr[$i] is not an array. It can also happen if $_arr[$i] has not been set. Try putting "print_r($_arr[$i]);" just before the foreach.
  15. MD5 isn't really a random string generator, though it can serve that purpose fairly well. In case you desire a truly random distribution, you can use this function I wrote a while back: [code]function generatestring($len = 12) {     $chars = "abcdefghijklmnopqrstuvwxyz";     $chars .= strtoupper($chars);     $chars .= "0123456789";     $ch = str_split($chars);     $max = count($ch) - 1;     for ($i = 0; $i < $len; $i++) {         $return .= $ch[mt_rand(0,$max)];     }     return $return; }[/code]
  16. Just put it at the end. You may also want to use an ORDER BY clause. You can do ORDER BY RAND() if you want to display random images. [code]SELECT * FROM images WHERE subID='$subID' AND imgFeatured='no' ORDER BY RAND() LIMIT $startrow, $rows_to_return[/code] Also watch your quoting, leaving $subID bare could expose you to an SQL injection attack, even with magic quotes turned on.
  17. Single query solution (requires MySQL 4.1 or greater): [code]SELECT t.* FROM myTable t INNER JOIN (    SELECT product, MAX(date) as maxdate FROM myTable GROUP BY product ) m ON m.product=t.product AND m.maxdate=t.modDate[/code] It will help to have an index on the `product` column.
  18. MySQL has a permissions structure of its own. You have to create a user root@xeon and give it permission to access data. [a href=\"http://dev.mysql.com/doc/refman/4.1/en/adding-users.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/4.1/en/adding-users.html[/a]
  19. If you need a multi-server solution you're probably better off using your first method. There shouldn't be any problem saving binary information in a BLOB. You're limited to a query size of about a meg though, so you may have to be clever about it to save files larger than 1MB. Also note that BLOB is limited to 65kB, so you may want to use MEDIUMBLOB. Multi-server solutions for method 2 do exist. For instance, regular synchronization via a cron job that does an FTP transfer. Also you could share a disk volume via Samba or NFS. Or you could just store images on a single server and make images from all sites pull from that URL. That might expose a domain you don't wish to expose, though.
  20. From the documentation: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] Note: The syntax for multiple-table DELETE statements that use table aliases changed between MySQL 4.0 and 4.1. In MySQL 4.0, you should use the true table name to refer to any table from which rows should be deleted: DELETE test FROM test AS t1, test2 WHERE ... In MySQL 4.1, you must use the alias: DELETE t1 FROM test AS t1, test2 WHERE ...[/quote] So try this: [code]DELETE FROM virtualdb_bu2 USING virtualdb_bu2 c LEFT JOIN mtable_bu2 w ON c.mlsnum = w.ListID WHERE w.ListID IS NULL [/code]
  21. Not really, but PHP's mysqli extension has a mysqli_multi_query() function that sends several queries at once. mysqli is still not supported by a lot of web hosts though.
  22. Try $count = mysql_result($mnum, 0, 0);
  23. Using single quotes (') makes MySQL think it's a string. Just treat it like a column name both times. [code]update tablename set amount = amount - 1 where ID = '005';[/code]
  24. Where it discusses the REGEXP fucntion there is a link to another section of the manual just for regular expressions.
×
×
  • 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.