Several years ago I created PHP class Quick_CSV_Import to import CSV files to a database table very quickly (LOAD DATA INFILE statement). I found that the class became quite popular in India due to feedback received :]
Now I want to share a little application on the basis of that class.
“Quick CSV Import with Mapping” is a PHP example application that imports CSV file to a database table with visual mapping of CSV columns to table columns.
Of course, you can get a copy of the application source – just go to the SVN repository.
Don’t forget to send me your feedback and donations ;]
P.S. If you are having problems with going to step 2 while using the app, try the following:
Open Quick_CSV_import.class and find “LOAD DATA INFILE“
change it to “LOAD DATA LOCAL INFILE“
It’s connected with permissions at your Linux server. Thanks to Noel for the solution.
Once upon a time I took a look at my Google Analytics account and found out that phpclasses.org is 5th source medium for two my blogs (this one and my russian blog).
I have 8 classes submitted. Calculation shows that 7% of my blogs visitors are my classes downloaders and viewers for all the time my classes and blogs exist, and 11% – for last week.
Take into account, that
I get these people to me without any move – I have just placed the links once.
in-bound links improve Google PageRank
count of links is limited only by your imagination ;]
To check that all my classes have all needed links in “Related links” section, I wrote a PHP script that adds a link if it’s not present on your class page. It was written fast so there not so much error checks; to use it, just
type your login/pass,
list IDs of your classes and
define the list of links to be placed in “Related links” section of every class page.
Script supports more than one login/pass pair. If such link is already present, it will be skipped. CURL is required for your PHP server.
Another my class has become a winner of PHP Classes Innovation Award – it’s the implementation of Binary Search algorithm. Yes, it’s the algorithm we all know from university – it’s strange for me, that it was considered as innovative.
I wrote this class as a test task while an interview for a new job. Results were so impressive for me, that I decided to share this piece of code: it finds result in 10Gb file for less than 5 seconds! File must contain key/value pairs (separator can be defined, by default it’s equal sign), and these pairs are sorted by keys. You define what key to search and get correspondent value very quickly.
If you search “Sandy”, you’ll get result “8”. Very quick :]
As a prize I selected an Apress book called “From Program to Product” – though I found it in PDF, it seems to be quite insightfull for me: we, developers, always think about code, and never about how to sell it. I have several product ideas, so I hope the book would help me to succeed.
P.S. Fun is that a few people emailed me to say how nice my new PHP Classes avatar is :] Thanks to Anton Dovgal for such a great picture of sad me.
I have intention to complete my draft of a CRUD PHP-class. Don’t know what is it? Easy!
Imagine you have a site where users point some places at Google Maps framed at your page. As developer of this site you will have to create several admin pages:
a page to manage users: e.g. grant permissions to your friend or deactivate a gonzo user
another page to tune options of the map points: fix a typo or edit coordinates of points
Just two pages, but I bet you’d need at least 3-5 hours to make a small draft form to manage these entities. To make things worse, let me remind you of paging, client and server sides validation, date-picker dialogs or even data integrity checks.
So, to cut the long story short, CRUD class generates all this for you in a couple of lines of code. So you just define what database table you’d like to manage – drum-roll! – you get a ready-made interface! (I call it a Table Manager Class – it helps you to manage any table in your system)
By the way, CRUD stands for Create, Read, Update and Delete. So CRUD class allows to play with data you have.
As Petrovich said (a laboratory assistant in my university), “first check what others have done”.
While the former is rather crude (it doesn’t work in some conditions, settings are embedded in PHP code), Symfony’s generator is quite nice: settings are separated from logic in a Yaml file and the code is being regenerated for you every time you make a change.The drawback of the latter is that you have to deal with huge Symfony framework to have this feature.