Quick CSV import with visual mapping

development, php, php classes 156 Comments »

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.

CSV Mapping Master - click to download

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:

  1. Open Quick_CSV_import.class and find “LOAD DATA INFILE
  2. change it to “LOAD DATA LOCAL INFILE

It’s connected with permissions at your Linux server. Thanks to Noel for the solution.

Using PHPClasses.org for marketing purposes

ideas, marketing, php, php classes 2 Comments »

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

  1. type your login/pass,
  2. list IDs of your classes and
  3. 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.

You can download it and use for free.

Delete Your Code #1: time calculations

delete your code, development, php Comments Off on Delete Your Code #1: time calculations

You can be (rich and healthy) or (poor and ill).

You can have (readable and laconic code) or (confusing one).

Oh no, I’ve said too much. I haven’t said enough” © REM. The following two examples do the same – so choose any ;]

echo time() + (60 * 60 * 24 * 14); //14 days from now
echo strtotime( '14 day');

Second variant also allows things like ‘-2 years‘.

Want the same in MySQL? Not a problem:

SELECT DATE_ADD( NOW(), INTERVAL 14 DAY )

Another PHPClasses victory

php, php classes Comments Off on Another PHPClasses victory

September 2008 WinnerAnother 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.

For example:

Ann=5
Bob=3
Sandy=8
Zulu=1

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.

Phonetic won!

development, php, php classes 5 Comments »

winner1.gif align=Yes, my class Phonetic won the first place of the PHPClasses Innovation Award.

Thanks to everyone voted for me!

You can check a demo here.

Vote for Phonetic class

development, php, php classes 1 Comment »

My PHP class Phonetic is nominated on phpclasses.org Innovation Award.

Vote for it!

The class generates words that phonetically are equal to the given one, but are written differently.

CRUD Class

php 6 Comments »

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”.

So, I found a CRUD class and I remember about Symfony framework admin generator.

CRUD class

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.

Symfony admin generator

So my idea is to prepare a stand-alone PHP class to make generation of admin inteface easier. I’m going to use an Ext.js JavaScript framework to beautify the interface.

Maybe someone has a better solution?

Andrisi suggests this to be like this:

A draft of CRUD

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in