http___blog.petkanski.com_2011_04_mysqlrealescapestring.html_1.xml
http___inspirevolunteer.co.uk_staff-interview-maria-moreno_.xml
1.1 2.1 2.2 2.3 3.1 4.1 4.2 5.1 5.2 5.3 6.1 7.1 8.1 9.1 9.2 10.1 11.1 12.1 12.2
По темата.. Днес ми се наложи да сравнявам предимства и недостатъци на няколко framework-чета. При едното от тях липсваше вграден database model, така че се наложи да ползвам нещо отделно. В конкретният случай се спрях на PDO и реших да си напиша няколко базови класчета.. За да съкратя историята, направо ще ви синтезирам това което Ви е нужно да знаете ;) При МySQL имате два вида сравнение на низ от символи (string) - това са равенство и сравнение с pattern, посредством LIKE или регулярен израз. В моят случай използвам LIKE, защото е най-бърз за имплементация и защото отговаря на нуждите ми и няма смисъл от overengineering. Случаят е простичък - имам данни в базата, имам и търсачка която търси с LIKE. Това което ме изненада, беше, че mysql_real_escape_string() допусна символи в низа които са със специално значение, а именно - символите за процент (%) и долно тире (_). В най-общият случай - при вмъкване на данни или сравнение със равенство това не ви бърка, но когато ползвате LIKE нещата стоят по малко по-различен начин. Получи се ситуация, при която аз търся в базата данни къде е споменато "100%", но тъй като символът за процент не се escape-ва, се получава, че търся низ който съдържа 100. SELECT * FROM SomeTable WHERE `textField` LIKE '%100%%' Очевидно, това не е поведението което би се очаквало, след като имаш илюзията, че данните са ти escape-нати правилно. След като разбрах какъв е проблема си помислих, че може би е проблем на mysql_real_escape_string() и веднага си отворих http://www.php.net/mysql_real_escape_string - но се оказа, че това е очаквано поведение. В документацията на функцията ясно са писали, че тя "prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a". Ето го точният цитат от сайта: Може би символите за wildcard попадат точно в тези изключения които са споменали.mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.This function must always (with few exceptions) be used to make data safe before sending a query to MySQL. Изводът е простичък - винаги минавайте един профилактичен str_ireplace() или preg_replace() на данните които използвате при генериране на заявка за търсене в базата данни за да няма изненади. Нека това, че ползвате prepared statements не ви дава чувство за сигурност.
1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 9.2 9.3 10.1 11.1 11.2 12.1 13.1 13.2 14.1 15.1 16.1 17.1 17.2 17.3 17.4 18.1 18.2 18.3 18.4 19.1 20.1 20.2 20.3 20.4
Staff Interview – Maria Moreno, Cambodia Manager Warning: mysql_real_escape_string(): No such file or directory in /var/sites/i/inspirevolunteer.co.uk/public_html/wp-content/themes/nouveau/includes/shortcodes/shortcodes.php on line 3244 Warning: mysql_real_escape_string(): A link to the server could not be established in /var/sites/i/inspirevolunteer.co.uk/public_html/wp-content/themes/nouveau/includes/shortcodes/shortcodes.php on line 3244 Warning: mysql_real_escape_string(): No such file or directory in /var/sites/i/inspirevolunteer.co.uk/public_html/wp-content/themes/nouveau/includes/shortcodes/shortcodes.php on line 3244 Warning: mysql_real_escape_string(): A link to the server could not be established in /var/sites/i/inspirevolunteer.co.uk/public_html/wp-content/themes/nouveau/includes/shortcodes/shortcodes.php on line 3244 Warning: mysql_real_escape_string(): No such file or directory in /var/sites/i/inspirevolunteer.co.uk/public_html/wp-content/themes/nouveau/includes/shortcodes/shortcodes.php on line 3309 Warning: mysql_real_escape_string(): A link to the server could not be established in /var/sites/i/inspirevolunteer.co.uk/public_html/wp-content/themes/nouveau/includes/shortcodes/shortcodes.php on line 3309 What position do you hold at Inspire? I am the Cambodia Country Manager. I’m here to make sure volunteers have an amazing time while they are in Cambodia and that our programs make a positive impact in the communities that we serve. I work closely with program partners to identify community needs and develop engaging volunteer projects. What did you do before you started working for Inspire? I worked as an on-site intern with the Thailand team for five months in 2013 prior to taking the position of Cambodia Country Manager in January 2014. Prior to my time in Asia, I worked with various community organizations working on human and civil rights issues in both the U.S. and Chile. What inspires you most on a daily basis? I would say there are two main things that motivate me: working with local partners and working with volunteers. I love seeing the impact that Inspire’s programmes have in the community and building strong relationships with our local partners. I also love working with volunteers and accompanying them through their journey of discovering a new place, trying new foods, expanding their horizons and growing as an individual. What should participants know about Cambodia when considering it as their volunteer abroad destination? Cambodia has some of the nicest, warmest people in the world – it even competes with Thailand for the title of “the land of smiles”. I think some volunteers have been surprised with the amount of development in Cambodia. They expect to be out in the countryside without access to internet or many modern comforts. There is quite a mix in Cambodia – between the old traditional lifestyle and the modern lifestyle. You can easily spend time in the countryside without running water and then go to the city where you can readily get access to wi-fi and eat a wide array of western and local food. It’s also worth noting that Cambodia is HOT! So be prepared for the heat and humidity. During the months of July-October is also the monsoon season where there is quite a bit of rain. If you are planning to come during the rainy season, be sure to bring a raincoat and plenty of mosquito repellent. What makes the Inspire programmes in Cambodia so unique and special? There are a wide range of programmes in Cambodia, which makes it a unique place to come and volunteer. Whether you’re interested in volunteering at a medical clinic, developing a sustainable garden, teaching English, playing sport, or getting involved with our women’s empowerment programme – you can do it all in Cambodia! Our programs are based in the lush Cambodian countryside, giving you a unique glimpse into day-to-day life. The city of Battambang is also laid-back and a great place to meet some amazing people and get away from the tourist traps!