Top 20+ MySQL Best Practices
Database operations often tend to be the main bottleneck for most web applications today. It's not only the DBA's (database administrators) that have to worry about these performance issues. We as programmers need to do our part by structuring tables properly, writing optimized queries and better code. In this article, I'll list some MySQL optimization techniques for programmers. Before we start, be aware that you can find a ton of useful MySQL scripts and utilities on Envato Market. Most MySQL servers have query caching enabled. The main problem is, it is so easy and hidden from the programmer, most of us tend to ignore it. The reason query cache does not work in the first line is the usage of the CURDATE() function. Using the EXPLAIN keyword can give you insight on what MySQL is doing to execute your query. The results of an EXPLAIN query will show you which indexes are being utilized, how the table is being scanned and sorted etc... After adding the index to the group_id field:
PHPExcel - Home
extremely useful PHP classes
PHP PSD Reader A few weeks ago, I wrote an article about this PHP which allow you to display any Adobe PSD file on screen. Very usefull to create preview of PSDs designed for clients, for example.Download Browser detect One of the most common (and boring) problem for front-end developers is definitely cross-browser compatibility. This PHP class will detect almost all browsers and simplify your cross-browser work.Download Akismet Remember those days without spam? ADOdb The large majority of websites and web apps are using databases to store all kinds of data. HTML Purifier As it name tells, HTML Purifier is a PHP class created to help you writing a better code. Google charts API Charts are very useful and highly asked by clients, but they can be a lot of work. pChart pChart is another chart class, and it is as good as Google charts API. PHP Excel Excel documents are highly popular in the corporate world. Country from IP Cache Manager WPGet
Object Oriented PHP Tutorial for Beginners - KillerPHP.com
Preamble The hardest thing to learn (and teach btw,) in object oriented PHP is the basics. But once you understand them, the rest will come much, much easier. But don't be discouraged! You just found the easiest to understand tutorial out there on OOP and PHP. … Or so I've been told. About This Tutorial This tutorial is designed to teach total beginners object oriented PHP. This is not a long-winded theoretical blathering that you see all too often; instead, we actually start writing OO code very quickly. So before you begin, get out your favorite PHP code editor and be ready to write and run some object oriented PHP code. PS: scroll to the bottom of the page for the supporting videos. Thanks for reading,Stefan Mischook Introduction With the release of php5 in 2004, php programmers finally had the power to code with the 'big boys'. In this tutorial, you will be guided (step-by-step) through the process of building and working with objects using php's built-in OOP capabilities. OOP Videos
15 very useful PHP code snippets for PHP developers | ViralPatel.net
Following are list of 15 most useful PHP code snippets that a PHP developer will need at any point in his career. Few of the snippets are shared from my projects and few are taken from useful php websites from internet. You may also want to comment on any of the code or also you can share your code snippet through comment section if you think it may be useful for others. 1. Send Mail using mail function in PHP 2. 3. The above code will not work in case your client is behind proxy server. 4. This function will return the duration of the given time period in days, hours, minutes and seconds. e.g. secsToStr(1234567) would return “14 days, 6 hours, 56 minutes, 7 seconds” 5. 6. Required Extension: SimpleXML 7. 8. Following is the PHP code to create the JSON data format of above example using array of PHP. Following code will parse the JSON data into PHP arrays. 9. 10. This basic snippet will create a random authentication code, or just a random string. 11. Validate a date in “YYYY-MM-DD” format.
Easy Ways to Sort Arrays in PHP
Tutorial by Matt Doyle | Level: Beginner | Published on 16 August 2010 Categories: Learn how to sort arrays quickly and simply in PHP. This tutorial shows you how to sort indexed, associative and multidimensional arrays using some handy PHP array functions. As I mentioned in my earlier article, Creating Arrays in PHP, arrays are very useful if you need to store and manipulate a large amount of data in one go. PHP gives you a large number of sorting functions that can sort arrays using many different criteria. We won't try to cover every single PHP array-sorting function in this tutorial. Let's get started! Sorting indexed arrays: sort() and rsort() The sort() function sorts the values in an indexed array in ascending order. $myArray = array( 1, 2, 'a', 'b', 'A', 'B' ); sort( $myArray ); // Displays "A B a b 1 2" foreach ( $myArray as $val ) echo "$val "; rsort() works like sort(), except it sorts in descending order: Sorting associative arrays: asort() and arsort() Here are some examples:
Twig - The flexible, fast, and secure template language for PHP
15 PHP regular expressions for web developers
Getting started with regular expressions For many beginners, regular expressions seems to be hard to learn and use. In fact, they’re far less hard than you may think. Before we dive deep inside regexp with useful and reusable codes, let’s quickly see the basics: Regular expressions syntax PHP regular expression functions Validate domain name Verify if a string is a valid domain name. $url = " if (preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(? » Source Enlight a word from a text This very useful regular expression find a specific word in a text, and enlight it. $text = "Sample sentence from KomunitasWeb, regex has become popular in web programming. Enlight search results in your WordPress blog As I just said that the previous code snippet could be very handy on search results, here is a great way to implement it on a WordPress blog. echo $title; Now, just before the modified line, add this code: <? Save the search.php file and open style.css. » Source » Source 'A(? <?
9 Tips For Working with MySQL Databases
MySQL is one of the most popular relational database management systems (RDBMS) around, with over 6 million installations. It’s a fantastic choice for any new developer, because of its open source nature, wide support and abundance of tutorials available on the subject. Here are some great tips and tools (beside phpMyAdmin) to improve your MySQL coding, and to help you save time. Installing SQL If you’re a newbie to the server side coding arena, don’t worry. Mac only PHP, SQL & Apache Installer Windows, Linux & Mac installer A windows only LAMP installer MySQL Server 5.1 If you just want MySQL server, and like using command line then this might suit you. For info on how to install and work with the MySQL server, check this NetTuts tutorial: Everything You Need to Get Started With MySQL. SQL Tips 1- Optimize your code Imagine if you have 100 records, 10 columns.Your working with a database of your clients details, and need to select their name, phone number and address. SELECT * FROM clients;