http___blog.petkanski.com_2011_04_mysqlrealescapestring.html_1.xml
http___inspirevolunteer.co.uk_volunteer-teaching-abroad-with-inspire-by-kirsteen-volunteer-advisor_.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 8.2 8.3 8.4 9.1 9.2 10.1 11.1 11.2 12.1 13.1 14.1 15.1 16.1 17.1 18.1 19.1 20.1 21.1 22.1 23.1 24.1
Volunteer Teaching Abroad With Inspire, by Kirsteen, Volunteer Advisor 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 Inspire are proud to work with some amazing partner schools in Romania, India, Nepal, Thailand, Cambodia, Tanzania, and Peru. We offer options to volunteer at nursery, primary and secondary schools in locations such as Cusco in Peru, Arusha in Tanzania and in the Transylvania region of Romania. We also work with small community schools in rural locations, including Kalimpong in India and the hill-tribe region in Northern Thailand. We also offer a unique opportunity to teach English to novice monks at Buddhist temples in Chiang Mai in Thailand and Battambang in Cambodia. Our volunteers work alongside the local teachers and help students with English grammar, reading, maths, science and geography. Some of the schools also offer opportunities to teach music, dance, drama, art and sports. Volunteer teaching abroad can be an extremely rewarding and enriching experience, and it is an opportunity to step out of your comfort zone and do something challenging and exciting. It is not necessary to have any previous teaching experience to participate in an Inspire teaching project, however it is essential that volunteers are enthusiastic, lively and motivated. Our volunteer teachers will receive a 10 page guide to teaching English in their Inspire briefing pack which will give them advice about teaching techniques and planning lessons, and they will also have support and guidance from our in-country teams and the local teachers at their school. Here are our top 10 tips for volunteer teaching abroad – - Be enthusiastic, energetic and confident - Plan and prepare your lessons in advance - Make your lessons as interactive and fun as possible (remember that you may have very few resources so you will need to be creative and come up with new ideas – quizzes, competitions and songs usually go down well) - Show an interest in getting to know the students, learn their names, and encourage them in their pursuit to learn English - Be patient and don’t overwhelm your students with too much information - Be personal -tell the students about your family/ friends and your life at home, and show them photos and postcards. - Be inspiring and engaging – ask the students about their plans for their future and encourage them to have dreams and aspirations - Be flexible and accept that sometimes you will need a Plan B (so it is always a good idea to have some fun quizzes or activities up your sleeve) - Learn a few words in the local language - Have fun! If you would like any further information about Inspire’s volunteer teaching projects please call us on 01635 45556 or email [email protected] By Kirsteen Mahoney, Volunteer Advisor – Inspire