Jump to content

gvp16

Members
  • Posts

    85
  • Joined

  • Last visited

Everything posted by gvp16

  1. Good adivce, thank you.
  2. I have been been coding in php for about 5/6 years. While at uni I was taught the procedural way, and using all the myql_ functions to do database work. Generally speaking if you google for php coding examples you tend to come across examples using those methods which I now believe are out of date. In recent years I have learned some MVC, and used some frame works and open source applications (opencart, wordpress etc...) So im just wondering, these days if you had to write a basic script to get information from a database how would you go about it? or say you were going to make a basic 5 page website with php how would you set it up? The reason im asking these questions is because I want to get out of bad habits and using outdated methods so rather than write something like the following what would you do? $dbh1 = mysql_connect('localhost', 'user', 'password') or die(mysql_error()); //DB connection mysql_select_db('db_name', $dbh1);//choose correct database $query = "SELECT * FROM table WHERE something = something"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_assoc($result); echo$row["field"]; How would you set up a basic website (content pages,contact form)? In the past I have done something this : request ---> index.php (get page & content from db) ---> pass info to content.php As i said im looking to get out of bad habits and essentially get up to scratch on modern day practices for basic projects, using a framework or CMS for such simple things seems like overkill. Thanks.
  3. I know this question has probably been asked over and over but im interested in getting some opinions in my particular case. I need to develop a system which will be used to generate custom content for a website. There isnt anything over complicated taking place but that doesnt mean there wont be either! Im talking database queries, and some logic. So the question im asking my self is to write a custom application (mvc) or use a frame work. But before everyone starts chanting to use a frame work consider the following points. Reasons to build custom: I am the only developer in the company, and will be for some time. Some of the modules needed will be very bespoke and I need full control over everything. I dont currently know any frameworks and will have to learn one, during this time I could complete half the application (made a small start on it) and have plenty of other things to do. The application would be build for its purpose and nothing else. It will be well documented so should I new developer join the team (or replace me) then along as they have an understanding of php mvc they should get on fine. I would enjoy it to be honest! With that in mind I am fully aware of the benefits of going open source, eg CodeIgniter, cakephp etc... Community help, plugins, lightweight, learn new skills etc... Im just trying to decide what will be the best option here and if anyone else has had a similar situation. Thanks.
  4. Yes, what I have just tried and seems to work well is adding in a "keyword" column to the table, so for example all mountain bike helmets now have mtb helmets as a keyword and so on, the performance is 100% better as well. Thanks for all the advice!
  5. When I do MATCH() AND MATCH() it does run faster however I dont get the results from the products with mtb. I have also tried doing this : MATCH (Product_Name,Cat1,Cat2,Cat3,Colour,Size) AGAINST ('mtb +mountain* +bike* +helmet*' IN BOOLEAN MODE) And removing the other match from the query, but I get the same results as MATCH() AND MATCH(). Thanks.
  6. In what way : like WHERE Product_Name LIKE '%mtb%' AND Product_Name LIKE 'Mountain bike' for example.
  7. Yes I know the LIKE isn't a great idea, some idiot made a mess of the data and put image urls as the product name for some items (this gets updated regularly so If I delete them from the DB they will come back). That aside when removing that from the query it doesn't seem to aid in the performance at all. The problem is I need to return results for both mtb and mountain bike, as depending the type of product there will be occurrences of both. Unfortunately I don't have control over the product titles so I couldn't standardise them either. There is a spellchecker in place as well, so if someone does spell mtb or mountain wrong it is normally corrected. Thanks.
  8. Hi all I have a full text product search query that is built up via php and certain elements are changed based on the search query. The query runs well and the results are very accurate and what we want, however it takes roughly 0.5s - 1.5s to run, as this is used in an ajax search there is a noticeable delay. So im looking for some advice on how I can improve the query. I think I have isolated the problem, some of our products are named slightly different but to the end user are the same thing, so for example an mtb helmet is the same as a mountain bike helmet. As such I wrote in some php to add in the additional keywords when the opposite is being search for. SELECT Product_Name, URL, ImageURL, StockPrice, Brand , MATCH (Product_NAME) AGAINST ('2014') + Rating * 0.1 + views * 0.1 + addedtobasket + MATCH (Product_Name,Cat1,Cat2,Cat3,Colour,Size) AGAINST ('+mtb*' IN BOOLEAN MODE) + #This line here is added when the term mountain is search for MATCH (Product_Name,Cat1,Cat2,Cat3,Colour,Size) AGAINST ('+mountain* +bike* +helmet*' IN BOOLEAN MODE) as Score FROM products WHERE MATCH (Product_Name,Cat1,Cat2,Cat3,Colour,Size) AGAINST ('+mtb*' IN BOOLEAN MODE) + #This line here is added when the term mountain is search for MATCH (Product_Name,Cat1,Cat2,Cat3,Colour,Size) AGAINST ('+mountain* +bike* +helmet*' IN BOOLEAN MODE) AND Cat1 != 'Admin' AND Status = 'True' AND Cat1 NOT LIKE '%prodimg%' AND Stock_Level > 0 AND StockPrice > 0 AND date_updated > '2013-09-26 10:48:03' AND ProductID != '' GROUP BY ProductID ORDER BY Score DESC, Rating DESC When the addition line is added the query takes roughly 0.875s to run, without it comes back as 0.05s there is a large improvement on speed but an impact on the results. I have the following index as well : Any suggestions? Thanks.
×
×
  • 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.