Friday, June 21, 2013

SQL. Sort in a Group

I was looking for a SQL statement to sort the data in a group. For example I have a table "logs". In "logs" I keep the users visits. If you log in into the system I record the event with the date and time. Very often I have been asked to answer the question when the users visited the site for first time or when for last time. So I need to create a list of user names and next to it the date and time for the first or last visit. So far I was doing this using stored procedures or in a program. Recently my friend Victor showed to me the solution bellow. I don't know if that actually works for my case.
You can find the original post here: http://bin.cakephp.org/view/1153419505

                FROM(
                SELECT Message.*, Job.*, Sender.*
                FROM (
                (messages as Message
                LEFT JOIN users as Sender on Message.sender_id = Sender.id)
                LEFT JOIN  
                (jobs_messages as JobsMessage LEFT JOIN jobs as Job ON JobsMessage.job_id = Job.id)
               
                on Message.id = JobsMessage.message_id
               
                )                
                ORDER BY Message.id DESC
                ) as result
                GROUP BY Job.id, Sender.id

Monday, June 17, 2013

Stop a program, which during startup installs and runs a service in Winfows XP

Recently I wanted to start an old MySQL server on Win XP. After starting it a service was installed in the system. Each time I restart my computer the service was installed and started. I had another MySQL server running on the same machine. I didn't want to identical services to run. I had to stop the program that installs and runs the service. There was  a program installing and running the service (WinMySQLAdmin)
This is what I did. You can find other useful commands in the screenshots.








Sunday, June 2, 2013

How to participate in a project using Codenvy and AppFog

I have started a Zend Framework, 2 Doctrine 2 projects for my students. You can find it in GitHub https://github.com/wingman007/fmi. To make the things easier, I have compressed the folder "vendor". So you can find the file "vendor.zip" in the repo. The folder vendor have been created using "composer". But in environments like "Codenvy" we don\t have console and can not run composer. In such cases we can use the archive "vendor.zip". Simply unzip and replace the folder vendor.
In this tutorial I show how to clone (fork) FMI project in github, clone the fork to cloud IDE "Codenvy" and deploy it to AppFog. I show also how to run a MySQL service on AppFog and install phpMyAdmin in order to manage the instance.