Jump to content

asmith

Members
  • Posts

    967
  • Joined

  • Last visited

Everything posted by asmith

  1. I see. I guess I could add 'OR name_column LIKE '%mykeyword%' add the end of the statement so that if fulltext failed, it searches with LIKE. But still this makes the query bit heavier and MySQL is not really good at searching large data. I have sphinx setup for another table though, ultimately I'll add this table too. :/
  2. Are you suggesting to get rid of the fulltext index/search? it is not possible to find those conditions with fulltext?
  3. Found this thread: http://forums.phpfre...grating-to-ipb/ I've been with phpfreaks for some years, I can't believe phpfreaks did that. To me it seems more like something personal with SMF rather than analyzing 2 softwares and picking one. phpfreaks kinda lost attraction to me. I hope I'm wrong and it is doing even better than ever.
  4. Hello, This is kinda driving me crazy. My search key words doesn't seem to return the result I want. I have this name that ends with a name like this: something_mykeyword So I use FULLTEXT for MATCH(name_column) AGAINST ('mykeyword') and it doesn't find the row. The manual says that * in boolean mode must just append. In this case I need it to be like this: MATCH(name_column) AGAINST ('*mykeyword' in BOOLEAN MODE) Let's say the record doesn't end and mykeyword is in the middle of a bigger word: somebiggermykeywordlying around How do you find it with FULLTEXT? Thanks for your time Mysql 5.5
  5. Do you mind telling me what was wrong with SMF?
  6. Ok here's an update. str_replace() was kinda messing the string, because if 2 urls had same start and if str_replace() were doing the shorter one first, the second was getting half-way done and it produced broken urls. So, I sorted urls by length first: function bylength($a, $b) { $length1 = strlen($a); $length2 = strlen($b); if ($length1 == $length2) return 0; return $length2 > $length1 ? 1 : -1; } uasort($matches[0], 'bylength'); Everything's so far so good and fast enough
  7. Thanks DavidAM. Very detailed. I'll try this and see how much time it will take. Thanks for going into trouble for me
  8. Thanks for the reply. It is all clear. The $content is my example is the whole html output. My code scans the whole output and replace urls with new ones. Your code is dealing only with one url. So I assume you mean, I get all the urls in the output myself in an array, then run each of them by this function.
  9. isn't mod_rewrite an Apache/webserver module for resolving friendly urls to their actual address? I'm trying to do the other way around. Make my boards friendly then use nginx and use its mod_rewrite to resolve these back.
  10. Hello, I'm rewriting my boards names. The original is like SMF: (first number is board id, second is board page) example.com/index.php?board=1.0 to example.com/name-of-board/ if page number is 0 (board=1.0), then page won't be in url: example.com/name-of-board/ if page number is not (board=1.5): example.com/name-of-board-5/ I have an array, with board IDs as keys and values as board names: $new_names = array( 1 => 'new-discussion', 2 => 'feedback' ); Here's the first batch I tried. It is very slow, since I have more than 200 boards: <?php $url_input = array(); $url_output = array(); foreach ($new_names as $id_board => $name) { // When url has other variables. The output put ? at the end to not break other GET variables. $url_input[] = "'example.com/index.php?board=" . $id_board . "\.([1-9][0-9]*)[;&]'"; $url_output[] = 'example.com/' . $name . '-$1/?'; // When url has nothing at the end. $url_input[] = "'example.com/index.php?board=" . $id_board . "\.([1-9][0-9]*)'"; $url_output[] = 'example.com/' . $name . '-$1/'; // Should I go another round for when page number is 0? too nasty! $url_input[] = "'example.com/index.php?board=" . $id_board . "\.0[;&]'"; $url_output[] = 'example.com/' . $name . '/?'; // omg $url_input[] = "'example.com/index.php?board=" . $id_board . "\.0'"; $url_output[] = 'example.com/' . $name . '/'; } $content = preg_replace($url_input, $url_output, $content); ?> That's 4 rule per board (x 200). 800 rules, it is taking 0.2s to 0.5s! Any advise is greatly appreciated.
  11. That's my typo mistake when I was typing the question. That is rm.type.
  12. Hello, Using MySQL 5.5, It is actually so simple, I think I'm missing something in front of my eyes. I have these 2 tables: CREATE TABLE IF NOT EXISTS `records_members` ( `id_record` mediumint( unsigned NOT NULL DEFAULT '0', `id_member` mediumint( unsigned NOT NULL DEFAULT '0', `type` tinyint(4) unsigned NOT NULL DEFAULT '0', KEY `id_record` (`id_record`), KEY `id_member` (`id_member`,`type`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `records` ( `id_record` mediumint( unsigned NOT NULL AUTO_INCREMENT, `id_group` mediumint( unsigned NOT NULL DEFAULT '0', `record` float NOT NULL, `downloads` mediumint( unsigned NOT NULL DEFAULT '0', `posted_time` int(10) unsigned NOT NULL DEFAULT '0', `is_activated` tinyint(4) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id_record`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8; I want to get all the record by a specific member: EXPLAIN SELECT rm.id_member, COUNT(DISTINCT(r.id_group)) AS num FROM records_members AS rm INNER JOIN records AS r ON r.id_record = rm.id_record WHERE rm.id_member IN (95) AND rm.type = 0 GROUP BY rm.id_member This works fine as it is supposed to: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE rm ref id_record,id_member id_member 4 const,const 143 1 SIMPLE r eq_ref PRIMARY PRIMARY 3 test.rm.id_record 1 Same query, if I just request for much more members, it will does a full table scan: EXPLAIN SELECT rm.id_member, COUNT(DISTINCT(r.id_group)) AS num FROM records_members AS rm INNER JOIN records AS r ON r.id_record = rm.id_record WHERE rm.id_member IN (95, 956, 739, 363, 204, 920, 286, 40, 332, 1239, 989, 443, 347, 1122, 11, 75, 2238, 4, 1073, 5, 193, 591, 880, 361, 850, 499, 2213, 592, 133, 1802, 1702, 20, 2111, 1929, 63, 868, 698, 1923, 22, 1881, 507, 143, 785, 2, 586, 2172, 433, 827, 2216, 1987) AND crp.type = 0 GROUP BY rm.id_member EXPLAIN: id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE rm ALL id_record,id_member NULL NULL NULL 7701 Using where; Using filesort 1 SIMPLE r eq_ref PRIMARY PRIMARY 3 test.rm.id_record 1
  13. it is not members table to have pk and auto_increment. It is points table based on members activity and each member can have different points for different activity. The whole 6 columns must be UNIQUE for example: id_member member_type id_forum id_group id_sport id_season points 23 1 2 3 4 2 45 23 1 3 2 4 2 60 the first 6 columns must be UNIQUE.
  14. Hello, Using MySQL 5.5 and MyISAM tables. I have this table which stores points for members on different situations. Other than id_member, there are 5 other columns that specify these situations. 4 of these columns tiny int and one varchar 10. These 6 columns must be unique. So I made a primary key on all 6 and I update the system using such query: INSERT INTO points VALUES (x, y, ....) ON DUPLICATE KEY UPDATE points = points + VALUES(points) Everything works fine. I tried combining the 5 columns into 1 varchar field separated with coma. So that my primary key goes on 2 columns, id_member and id_situation. It is working with the same speed or maybe a little bit faster but combination of 5 values into one columns make things for other queries harder. I want to know is it a good practice to have primary key on 6 columns? Is there a big downside on such design? This table gets updated A LOT and it is easier for me to have the columns separated than combine them into one. Thanks for your time.
  15. asmith

    preg_replace

    Thanks for you detailed reply!! I've already started reading your tutorial.
  16. asmith

    preg_replace

    Hello, I'm getting entire site content and trying to replace old urls with new ones using this: <?php $urlin = array( "'somethingFile\?act=([a-zA-Z0-9\-]+);(.+)'", "'somethingFile\?act=([a-zA-Z0-9\-]+)'", ); $urlout = array( "somethingNew/\\1/?\\2", "somethingNew/\\1/", ); echo preg_replace($urlin, $urlout, $temp); ?> This works almost fine except that if I have 2 links in one line in html content: <a href="somethingFile?act=someAct;var=val"></a><a href="somethingFile?act=someAct;var=val"></a> The first link in the output gets replaced fine, but the second fails (gets matched with the second array value): <a href="somethingNew/someAct/?var=val"></a><a href="somethingNew/;var=val"></a> But if I split my string into 2 lines, all works fine: <a href="somethingFile?act=someAct;var=val"></a> <a href="somethingFile?act=someAct;var=val"></a>
  17. Thanks. both are good. I tried many words on Google. I didn't come across none of those.
  18. Hello, Windows shell32.dll icons, number 29 is a flat hand holding something: (it is windows shared icon) I am looking for a bigger size of this image. Not specifically this image, just a graphical hand in that form but that image is so much close to what I have in mind. I tried many words in Google but can't find a graphical hand just like that. Any idea? Thanks
  19. Not trying to be rude or anything. But your question is way too general to get any specific answers. This kind of topics usually gets abandoned because in order to answer it, someone gotta explain a whole database which is ambitious in many ways. So they won't bother.
  20. Thanks for the replies. @johnny86, I will have a problem with variables already defined. Other than that, that would be a nice solution. I said nasty because in case there are thousands of variables already defined. @requinix, I came across parse_ini_file but my problem is that I can't change the target file. It is a php script and must stay as it is.
  21. Hello, The plan is to get variables from a file and store them in an array. note that we don't know what variables the target file may have. For example the target file could be like this: <?php $a = 2; $b = 4; $c = array(1, 2, 3); ?> The result must be a variable like this: <?php $result = array( 'a' => 2, 'b' => 4, 'c' => array(1, 2, 3), ); ?> I have coded a solution. But I'm wondering if there could be easier ways I'm missing. So possible ways: 1. Get the file content, parse it line by line and possibly divide it by ; sign and start interpreting. (This is what I'm coding atm) 2. Include the file and compare the new variables to the ones before the include() which looks rather nasty. * I can't change the format of the target file. It's just a php script. * If your way requires a complicate regex, I'd be grateful if you show me the regex code. Thanks for your time.
  22. Hello, I'm trying to insert some arabic characters into MSSQL. I'm preparing the value with this: iconv('UTF-8', 'cp1256//TRANSLIT', $string); Which is working fine as it supposed to. The problem is the character ی. If a word contains it, that character gets deleted in iconv. Apparently it is not list in cp1256? The similar character to it is ي (with 2 dots under it) but it doesn't get converted to it. I tried replacing these characters manually and it worked fine. Wanted to know why it is not accepting that character and if there are better ways than replacing manually? Thanks for your time. PS. In a hex editor when I enter ی it gives me ? sign. but when I enter ي it gives me ED. Something is wrong with that character.
  23. You're right. Even if there was a way to save me more time, there will come a time when they reach 10,000 games and more and I'll be back here again. Thanks for the replay
  24. if ($row['moreThanTwo'] == 'yes') // Do stuff
×
×
  • 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.