Jump to content

iversonm

Members
  • Posts

    195
  • Joined

  • Last visited

Everything posted by iversonm

  1. Your stuff is not properly formatted. Please post the actual code and please post the class(es) that you are calling.
  2. Please post the php code and please post the form html.
  3. OK I guess I am not sure if this is the right thing to do but I changed it SELECT wowbb_topics.topic_id FROM ultra.wowbb_topics LEFT JOIN Rabbitry.wowbb_converted_topics USING (topic_id) WHERE wowbb_converted_topics.topic_id IS NULL LIMIT 100 and then I select the variables if I need them. It is executing in under a second now.
  4. iversonm

    Slow Query

    Hello. Just wondering if someone can tell me how to make this run faster. I need all the fields I am selecting. I am doing a conversion for a forum so what I did was create a table that stores the topic_ids that I have transferred and that is why I call a left join. I am not very good with mysql, just enough to make mistakes. SELECT wowbb_topics.topic_id, wowbb_topics.forum_id, wowbb_topics.poll_id, wowbb_topics.topic_name, wowbb_topics.topic_description, wowbb_topics.topic_views, wowbb_topics.topic_starter_id, wowbb_topics.topic_date_time, wowbb_converted_topics.topic_id AS old_id FROM ultra.wowbb_topics LEFT JOIN Rabbitry.wowbb_converted_topics ON wowbb_topics.topic_id = wowbb_converted_topics.topic_id WHERE wowbb_converted_topics.topic_id IS NULL LIMIT 1 We are look at around 30 seconds to execute this query.
  5. Christian, there will be an insert within the loop
  6. From the standpoint of coding. Pulling topics then posts for each topics then inserting, is that the best way to program that?
  7. Hey peoples I need some advice, I am working on converting a forum for someone as a favor. It is a forum with 70,000 topics and almost 1kk posts. I have already figured out how to convert the users to phpbb. Also forum data is extremely dirty. The guy who wrote the software didn't put in any validation. This forum has been going down lately for no reason and I am sure its due to issues with database info / structure. <?PHP $sql = 'SELECT forum_id, forum_name FROM Rabbitry.phpbb_forums WHERE parent_id != 0'; $query = MySQL::query($sql); while($row = mysqli_fetch_array($query)){ $forums_id[$row['forum_id']] = $row['forum_name']; $forum_name[$row['forum_name']] = $row['forum_id']; } $sql = 'SELECT topic_id, forum_id, poll_id, topic_name, topic_description, topic_views, topic_starter_id, topic_date_time FROM ultra.wowbb_topics'; $result = MySQL::query($sql); while($row = mysqli_fetch_array($result)){ foreach($row as $key=>$value){ $row[$key] = MySQL::escape($value); } $row['topic_date_time'] = strtotime($row['topic_date_time']); if($row['topic_date_time'] < 0){ $row['topic_date_time'] = NULL; } if($row['poll_id'] !== 0){ //get poll info } $sql_posts = 'SELECT wowbb_posts.post_id, post_text, attachment_id, user_id, post_date_time, post_ip, post_last_edited_on, post_last_edited_by FROM ultra.wowbb_posts INNER JOIN ultra.wowbb_post_texts USING (post_id) WHERE topic_id = \''.$row['topic_id'].'\''; MySQL::query($sql_posts); ?> I ran this, and it doesn't even have any insert statements and I let it go for 5 -6 minutes and it was still running. Any recommendations would be really appreciated !! I have never done anything this large from a conversion process. Matt
  8. OK so I am one step closed. First step is filtering out duplicates and organizing by level. Essentially sorting by rank without having a column for rank. This way it knows if you don't inherit anyone you are on the bottom of the chain...... $unsorted = $group_i; do{ foreach($unsorted as $Key=>$Value){ if(is_array($Value) && !empty($Value)){ foreach($Value as $K=>$V){ if(!array_key_exists($V, $unsorted)){ $array[] = $V; if(count($Key) === 1 && count($K) === 1 && count($V) === 1 && count($Value) && count($unsorted) === 1){ $array[] = $Key; } if(count($V) === 1){ unset($unsorted[$Key]); } unset($unsorted[$Key][$K]); } } }else{ unset($unsorted[$Key]); } } }while(count($unsorted) > 0); It executes pretty fast and I can't think of a better way. Now just have to loop through the results in this order to figure out the rest.
  9. Also I would like to add that at some point someone might make multiple permissions under one group. So Admin inherits Moderator and inherits Side_group. So this won't be a singular chain thus making it more complicated.
  10. I can't add to the table permissions_inheritance due to the fact it is used by an external java application. I can add another table for the ranks but for simplicity purposes I would rather not manage that too
  11. Basically what I want to do is create an array of inheritance. so here is the levels Owner->Admin->moderator->User->guest owner has all the abilities of admin, moderator, user and guest.. So I want to be able to sort through them and end with an array like this $array['Owner'] = array('Admin', 'Moderator', 'User', 'Guest'); Currently my code works sort of. Basically Admin is only set to inherit Moderator. Moderator only inherits User. So this code works but only to 2 levels. I don't want to add a billion foeachs within each other for each level(currently 4) but I might add more roils so then I would have to add more foreachs. There must be a magic way to do this. Any feedback is appreciated! <?PHP $sql = 'SELECT * FROM '.self::$Config['PERMISSIONS']['Database'].'.permissions_inheritance'; $result = DB::Query($sql); while($row = DB::fetch($result)){ if($row['type'] == '0'){ $group_i[$row['child']][] = $row['parent']; }elseif($row['type'] == '1'){ $user_i[$row['child']][] = $row['parent']; } } //echo count($group_i); print_r($group_i); $groups = array(); foreach($group_i as $Key=>$Value){ foreach($Value as $K=>$V){ $new_array[$Key][] = $V; if(isset($group_i[$V]) && is_array($group_i[$V])){ foreach($group_i[$V] as $Q=>$A){ if(is_array($A)){ foreach($A as $C=>$X){ $new_array[$Key][] = $X; } }else{ $new_array[$Key][] = $A; } } } } } Let me know if you have any questions! I hope you enjoy the challenge lolol
  12. BOOM. Exactly what I was looking for. I just had to add to $the_string on line 3(so it would use the right column for the mysql data) it works exactly as I wanted. I will let you know if I have any thing else that comes up. Thank you for your help
  13. Yeah that is very close. It just needs to know sort by where the periods are vs characters. some strings are essentials.admin.all where as some are hc.chat.all so the string length varies. they need to be broken up based on the periods because that is the breaking point for the different levels.
  14. OK so here is what I want to do. I have a bunch of strings stored in a table. The strings are like this grandparent.parent.child. some are just parent.child What I want to do is Select all and then put them into an array. soooo x.y.z would become $Var['x']['y']['z'] and a.b would become $Var['a']['b'] It has to be dynamic because some strings are just 2 levels, and it goes all the way up to 6 levels. I have different plans for setting the variably to something but I can handle that. Any ideas?
  15. Nobody is going to write the code for you. you need to try experiment, and then when you get stuck have us help. otherwise you can pay someone to write it for you
  16. ok thanks for answering my questions again i really appreciate your patience with me. I am learning a lot and I am sure anyone who is reading through this is learning a lot too. ill let you know if i come up with anything else
  17. one more question. so lets say you have 5 websites you are pulling data from and there are 10 different things you are collecting data on each website, but all 5 websites all have these 10 things. if you need to get the last result, selected results in a timeframe and all results would it be better to make a class for each site that have the same functions that implements an interface or make 3 classes and each class will either get lsat result, selected results, or all results and have a function in each class for each of the 5 websites? does that make sense?
  18. also other question, so if i have my proper interfaces and classes like memcache and mysql would it be proper to have a class for all user related functions? so in example registering, logging in, logging out? or is that not proper and should client code be in the form of a class or should it be procedural with no class?
  19. ok so looking at your example makes perfect sense to me now, but my other question now would be if i was using the mysqli extension should i build my own functions to query and all that sort of stuff that will utilize Procedural style or should i extend mysql class with mysqli. to me it would make sense to do the Procedural style and make my own functions so i can make sure they are all universal that utilize an interface in case i were to switch to mssql or something else but i want to just confirm that i am thinking correctly for this oo stuff
  20. yes you were right i meant i dont understand. ok so the idea of an interface is for uniformity. so a small example lets see i had a db classs that utilizes mysql then i made a new class that utilizes mssql for whatever the reason would be. the idea of the interface is to make sure its all the same and the class implementing the db1 or db2 class does not have to changed depending on which database im using if that makes sense? also unless i missed it why would you use static methods and then last for what i had inside my class functions to load things and do that stuff, should i just have that stuff run outside of my classes in a Procedural method or should i make a more classes for them?
  21. so a couple quick questions, whats the point of inside the SomeClassThatNeedsAccessToADb class inside construct function having Db before $db does that implement the interface. and i still understand how the interface helps if you know you have the connect and query function inside the db class i really do appreciate your help
  22. my other quick question for you before i really start getting into this is what is the point of a static method vs non static. what advantages do you have in declaring something static?
  23. im not trying to ask for you to write my script for me, but i will ask if you can show me an example or point in me in the right direction with a tut. iv been looking up proper oop structure but i dont quite understand how i would make what im trying to do fit into that structure. so to give you an example the global is my mysqli functions. would it make sense to extend the mysqli class to all the classes or am i missing the concept of oop as a whole
  24. well what can i do instead with the format? this is a learning process for me and i am not that best at oo structure but i don't want to drop the classes.. and that answer doesn't solve my problem for the overloading
×
×
  • 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.