Classes

To make programming easier, our teacher introduced us to classes. When you ask wiki : "In object-oriented programming, a class is a construct that is used to create instances of itself – referred to as class instancesclass objectsinstance objects or simplyobjects. A class defines constituent members which enable its instances to have state and behavior.[1] Data field members (member variables or instance variables) enable a class instance to maintain state. Other kinds of members, especially methods, enable the behavior of class instances. Classes define the type of their instances."


Just imagine we have a class called Dog.  A dog have variables like tail, nose, gender, and age. Methods like things that the dog can do like eat, pee, sleep, bark, etc. 


With classes, programming becomes easier because you can practically any class you have made before in any program as long as the situation applies. 


In our programming class, I was asked to create a mini-calculator that will basically add, subtract, multiply or divide 2 numbers using classes. Basically the 2 variables are the 2 inputed numbers while the 4 methods are the 4 different operations. I was able to pull it off. I will post the mini-program i made using php in my next post.

June 11, 2012: Connecting PHP to MySQL

Today were thought how to connect Php to MySql.
Syntax: mysql_connect(hostname, username, password)

We are also thought how to select database, execute query, check for affected rows, counting number of rows in a selection, fetching array all with php.
Syntax:
select- mysql_select_db("database",connection)
query- mysql_query(query,connection)
check affected rows (delect,update,insert)- mysql_affected_rows()
check number of rows (select)- mysql_num_rows(data)
Fetch array: mysql_fetch_array(data, array-type)

Array types:
1. default is MYSQL_BOTH
2. MYSQL_ASSOC (Display associative array only)
3. MYSQL_NUM (Display Numeric array only)

It was a good learning as we were able to write short php programs and play around with our sample databases.  I downloaded HeidiSQL as my SQL interface.  It works well with the WAMP Manager in our school's PC. I use Dreamweaver as an IDE in class. At home, I am using MAMP.

6/8/2012: SQL Introduction

Today I got introduced to SQL or standard query language. It was not hard.  The syntax is almost plain english.  The class was thought to use the console and not a GUI.  The exercise brought flashbacks about my MSDOS days.  The time when we use floppy disks the 5 inch thin floppys. Good thing storage memories are getting cheaper and smaller.

I was able learn how to a create database, how to create a table, how to input data, and how to view data.     We were using mySQL since the short course that I am taking is all about open source web development (LAMP).  I am using MAMP though because it so happen I am using a Macbook.  In class though, we are using WAMP since most of the computers here in the Philippines use Windows. The school is no different, I even find it odd that they offered a LAMP class but they do not provide computers that are LAMP ready.

A good resource about learning SQL or even other web development related programming is the http://www.w3schools.com/ website. While playing around with mySQL, I inputed the wrong data type in one of my fields.  The supposed syntax for changing according to my teacher was ALTER TABLE table_name ALTER COLUMN column_name datatype. After several attempts with this command, we keep getting error messages.  We check w3schools.com and it says the same thing. We even checked HeidiSQL.  We eventually figured out that it should be CHANGE COLUMN rather than ALTER COLUMN.

I had fun today and I am not really that scared with databases since I used to make dbase programs way back in 1992-93. It has been almost 20 years since I made program.   Luckily there is some sort of muscle memory that made me comfortable with databases. I am looking forward to using a GUI for SQL and also its integration with php and web development. ;)

Week 1: Going back to School

When was still high school, I was thought BASIC and some dbase programming. I was kinda good at it. I practically made many programs for my classmates.  I would say that I helped many graduate by making the main source codes of their final computer programming program.  It was fun but I did not proceed to Computer Science in college.

The winds brought me to different places.  I studied business. I worked mostly in sales and I have tried working in several industries.  I ended up in the Real Estate industry and I manage a sales group. My group is called the "Rainmakers". I got the name from the book by Jeffrey Fox. The group is doing well but I realized I can do more and be more.

I decided to enroll in a computer programming class in one of the local computer schools. I think it could be fun and you can never really stop learning. So far, so good. I had a hard time at first but eventually I am able to go up to speed.

This blog will be all about programming and how I applied it in my life. Hopefully, this blog will be able to help others by giving some information that can be useful in their own life. And so, it begins...