February 5th, 2010

We have seen that most of the time people write many lines of code. Might be the reason behind is that they either don’t know the capabilities of the each and every modules. Out of that different module one module is mysql.

As most of the websites having some kind of relational database. where their is one master table. and their keys are used in other tables. But if the programmer don’t know about the foreign keys then they write the code at the time of deleting the record e.g

Lets imagine that We have 2 tables

  1. Books
  2. Purchasers

people write following syntax.

create table books ( id smallint primary key auto_increment , name varchar(100));
create table purchasers (id smallint primary key auto_increment , bookid smallint , pur_name varchar(100));

While creating this, many programmer forgot major things. as they are creating these tables with storage engine as myISAM. but they forgot all transactional details need to be saved in InnoDB.  and current released version’s of mysql support foreign key for only innodb. and Now php is being concern they write code for 2 sql statement for deleting books and their purchasers. this is really bullship.

Now We have seen that when we got the work for existing websites. we seen similar things in many cases( almost all the cases). this really increases lots of efforts in programming as well as maintaining the codes. For owner of websites , they don’t bother(rather they don’t know) what other/older programmers written on it.  this increases our efforts even more. And now our database designer taking meetings with programmer and explaining the things was older database. so programmer have to find excessive work written on the code.  and replace with just simple modification made by our DB designer.

First Important thing needed is to first convert required tables into innodb

alter table books engine = 'innodb';
alter table purchasers engine = 'innodb' ;

Then Adding of foreign keys.

alter table purchasers add foreign key (bookid) references books(id) on delete cascade on update cascade ;

Doing This will add foreign key so that when we delete any book it will delete all their respective references given on purchasers table. which can be achieved with only single sql execute in php see the following line.

delete from books where id = _NUMBER_

some time we have seen that we have to drop foreign keys. and mysql manual says that use the following syntax.

alter table tableName drop foreign key keyName ;

But now the problem is that how to get that key name.  Then you need to use following way.

show create table tableName;

Doing this you will get name of foreign key. then delete the foreign key and index key.  Please note that when you want to add foreign key to any table try to make foreign key symbol name by your own rather than automated by mysql. This will easier for you manage and maintaining the all the keys. every foreign key comes with 2 kays one foreign key and one index key. if you just delete only foreign key then it will not be good way. as you are keeping garbage of index kay.

October 22nd, 2009

On October 17, Diwali we all friends gathered at our home. Lots of chat regarding new technologies and costing and future scope of all friends. One of my friend just come from US. As he is working their in some software company. Just for the curiosity , he asked me how much you charge for the project. Most of the time I generally prefer to work on fixed prized project. but now recently we have  seen that many customer like to change their requirement while seeing the progress of the work. so they doesn’t falled into fixed prize structure.

I told my friend that I generally charge 12 - 14$ per hour per man. He just shocked to hear my words. Saying me that this is one of the cheapest rate in US. As this charges are for unskilled labour over their. I said, I agree on this. but thats the reason you will save cost while transfering(outsouceing) work to us.

Many people thinks that if we are charging less means that we are not giving the quality. But Who told that quality having any relation with cost. Basically we keep our expenses very tight. We try to avoid extra cost which required for running business. As far as the quality is concern all our customers are satisfied with our quality. and they are still happy to give more work to us.

Its all depends how many work head your project requires. If something is giving less in cost then why to spend more money on expensive things.

April 22nd, 2009

Recently there was one requirement for one customer.  where we have to post data to twitter application. but twitter when submitting comments on twittter, twitter having limitation that it has only 140 characters to be posted for status. out of that customer wants to post their blog’s url as well.

Now things started making complicated. I have suggested him to doc one short domain but later realize that he doesn’t have option to part domain for their hosting. so I have been told to use API for which will programmatically convert long url into short url.  so I have  added this blog so that people will understand how to create program which will dynamically covert long url into shorter one.

All the methods which I have suggested based on php programming.

Requirement :

I have used some of higher php function for that it needs you have 5.2.0+ and JSON is integrated. and Curl option is enable for your domain.

There has been 2 sites which we are working on http://cli.gs and http://bit.ly now you have registered their site. I hope they are still free and get Key as basically these are the keys which want while processing.

cli.gs

For This site you need to understand POST is not accepted by cligs. so you have to send data in get method.

<?php

$key = "abe34849f398d02b83abf64ed6690ef5a"; // This will be your key
$tobeShorten = "http://www.runwalsoft.com/blog/index.php";
// This will be url which you want to make it short
$url = "http://cli.gs/api/v1/cligs/create";
$param = "url=". urlencode($tobeShorten) ."&title=This is testing&key={$key}&appid=RunBlog";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url . "?" . $param);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);

if($resultArray['http_code'] == 200)
{
  // This means that key is correct and the url which you have given is also working.
  echo "Short url is <b>" . $result . "</b>";
}
else
{
  echo "Error occured " . $resultArray['http_code'] ;
}

?>

Note : here key which I have written is dummy key. where you have to copy paste the key which you got from the site. and see you will get short url

Bit.ly

For Bit.ly there are few advantages and few are disadvantages. we can create 5 links concurently from same IP address. though that is really rare condition. advantage is that you can process multiple links at the same time. Means let say you want to convert 4 links in just one CURL call then it will be possible. and here you can use POST as well as GET mothod.

In both site you need to understand we have taken care of response from the server. if we got response header as 200 ( which means OK) then everything moving on is preety good. by default bit.ly provides response in JSON. I hope you know that thing. if you don’t know much just visit here its one of the simple method to process.

There is another option as well to process reponse as xml but I also still feel better to use JSON.

<?
$key = "R_c02b4ad85ccdsde92asdfe3951dfac08";
$username = "mrunwal" ;  // This is username when you register on their site.
$tobeShorten = "http://www.runwalsoft.com/blog/index.php";
$url = "http://api.bit.ly/shorten";

$param = "url=". urlencode($tobeShorten) ."&title=This is testing&key={$key}&appid=RunBlog";
$param = "version=2.0.1&longUrl=". urlencode($tobeShorten) ."&login=". $username ."&apiKey=" . $key ;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url . "?" . $param);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);
// Look at the returned header
$resultArray = curl_getinfo($ch);
curl_close($ch);

//Following is the method to handle json output

//This function REQUIRES you should have php5.2.0 +
$result = json_decode($result,TRUE);
// This is the response which you gets from curl
/* "errorCode": 0, "errorMessage": "", "results": { "http://www.runwalsoft.com/blog/index.php":
{ "hash": "ptlxO", "shortKeywordUrl": "", "shortUrl": "http://bit.ly/11vL1X", "userHash": "11vL1X" } },
"statusCode": "OK" */

if($resultArray['http_code'] == 200 && $result['errorCode'] == 0 && $result['statusCode'] == "OK")
{
  // This means that key is correct and the url which you have given is also working.
  echo "Short url is <b>" . $result['results'][$tobeShorten]['shortUrl'] . "</b>";
}
else
{
  echo "Error occured " . $resultArray['http_code'] ;
}

?>

Using this way it will be easier for you to process all shortenning of url. I hope you will feel better to use Runwalsoft’s programming for your current project. don’t botter to contact us.

April 12th, 2009

One day phone rang. some one heard about my work. and he wants to meet me. I have given him address and few members just arrived in our office. and they have narrated their problem in managing in multilevel marketing work. I said that their work will even much easier if they go with websites. and they can easily manage their down chain.

Requirement : This is really Big in their requirement. I know most of the multilevel marketting peoples really like to see this work. or even like to purchase similar software.  Let say there are some 50 forms which will be dispatched by admin and so they don’t have any sponsor. and each form will given to 50 person. and Once payment is received then each person we will deliver 4 forms.  In short in long run each person will have only and only 4 forms.

For Every member you have there is specific time [we called expiry] they have to sold their 4 forms. and once their 4 forms is sold then some sort of commission + gift will be given by owner.

…there are even more detail… stay tuned. wann visit site http://www.parasmanisuitings.com

if you want to create similar web site then we will arrage some demo of existing work so that you will get confidence and can able to see backend(back office work). This will helps you to manage your contents. Thats the benefits of Runwalsoft’s programming efforts.

March 5th, 2009

As this web site quite looks similar to albumhunt.com but there are many different things which was not in albumhunt or previous version of ahvideoz. as previous version of ahvideoz had problem of security which he wants to fix with new system. though system is already being ready 1 month ago. But there is drastic efforts was taken on testing this web site. when system was on alpha stage then old version web site reported one more problem that search feature is blocking/locking all the tables.

As any how we need to support that customer. though this part is their major problem and never like my customer in trouble. I told them that we need to upgrade

  • Mysql server
  • Installed Memcache module
  • Grant user for creating procedures, trigger, functions.

As server company was belong to his friend. and he is quite friendly with me as well. so upgraded the module. thought memcache need to add some part in our programming. this make that site even super fast. and load on the server was drastically reduced. as most of queries(lots of sql statement) are being executed in cache parts so its very obvious that program will be move faster.

Previous version belongs table structure. and new version of the site itself tableless structure so html pages are moving even more faster. This is the work which I really happy to deliver bcz lots of things working as per my expection. There is another project “parasmani suiting” for that I had contacted Indiatimes’s hosting panel but their staff are one the fool peoples. They have upgraded mysql to mysql5.0 but doesn’t provided permission to user for creating procedures , trigger or function. so I unable to provide advance features to my customer. Here in this case, hosting guys are really smart enough to understand technologies and ready to move for advance versions.

In this project we have used sprits as well. to understand sprite keep in touch with this blog. This whole work is carried out in smarty template engines. It looks that I fall in love with smarty. :)

This is how their new site looks like.

New Theme for Ahvideoz

New Theme for Ahvideoz

when ahvideoz saw this site then he is also happy to give his more work to runwalsoft. and thats what I called goodwill for me. There are some minor changes on the site and then we will move another work for this customer.

March 2nd, 2009

As most of the time I never accept the work from local customer. reason for doing is that they never pay on time.  But one day I had one phone call from my friend saying that ‘Manish , we have to do one web site.’ and he specifically looking for me to handle this work. But  schedule is so tight that I barely get time for this project. but he said he already commited that his site will be created by Runwalsoft itsself. so finally I keep his words.

So first we have shown him 5 template.  from which he likes 2 different things. some part of  first theme and some part of another theme. and our best designer have make such a fabulous themes and logo for them. which customer hardly objected. Work is started with daily updation and chatting with him, and we decided to move forward with smarty tempalte system. though my friend don’t know about net technologies but he trust me so much and given me full authority on technologies.

When work is on completion he decided to add few more points which was not the part of theme. but I also thought that he is saying correct. as majority of theme looks little white color. so later added few more designing things and great flash created by designer. and finally site looks like this. www.printitindia.com

PrintItIndia's Theme

PrintItIndia's Theme

when we tried to upload the site then found that there hosting was free hosting on godaddy. and godaddy having some extra code for free sites. They generally add extra Advertise on free site. but that advertise doesn’t look good on the site. which we really need to stop that. so we added one css coding which makes site really working good.

Customer also want that their product need to driven from admin panel. and they are displayed on index page with small scrolling between the product. so as per their expection we have finally deliver work in just 1 week. and he is so happy that I can not express in words.

January 27th, 2009

You might have seen that google, yahoo and many other sites are super fast. Though there are many thing which affect to make site super fast. But lets discuss some of the points which belongs to programming or programmer.

Most of the time what we design is much important. because if design is wrong then it will affect the performance of the site. let see following points step by step.

  • Database
  • Image Creation
  • HTML Pages
  • CSS Handling
  • Cache Utilization
  • Hardware related things [ This things belongs to hosting company so it will not be explain]

I will explain each points with you in short time.  stay tune.

January 18th, 2009

As mysql and mysqli both belongs to same mysql server. mysql and mysqli as just modules provided with php.

when we started working on php and mysql then only mysql module was provided and different hosting company even not updated their mysql for latest version. so specifically we had to use the old technique to access these things. now many things are changing.  People at the server company realize that they need to keep updated servers then only they will get more customer for their hostings. and now a days even customer are already known abt pros and cons of databases.

Now things begins here.  now you have old traditional web site which was created using old techniques and you want to make things more optimised and go with new cutting edge technologies. so there few things which you really need to keep in mind that now a days different layers are used for web sites. its not as easy as what traditional methods.  now on every front peoples are getting more advance. just for the sake of example. now for handling database there are dedicated peoples who knows clustering , memorycache ing for mysql. and in designing now advance flash version details are used with greate features. some templating used to keep site flexible to modify. and here we(Runwalsoft) have made all front details advance. each of our designer, programmer, database handlers are advance. they know how to tacles the hits. and how to mange more hits without losing their customers.

just for the sake of programmer. let say if you have used to open database connection you might have used.

$cn = mysql_connect('localhost','root','password') or die ('Unable to connect' . mysql_error());

which now you have to change like this.

$cn = new MySQLi('localhost','root','password','DatabaseName') or die("Unable to connect");

in the similar fashion you have to change queries as well previously we was using

$rs = mysql_query($sql,$cn) or die("Unable to find sql statement<br>" . mysql_error());

which is now

$rs = $mysqli->query($cn, $sql) or die("Unable to find sql statement <br>" . $mysqli->error);

I know that this is very very simple things but sometime people forgot how to use these.  so I am writting this for newbie. mysqli means that mysql improved. and it having my good features along with it. I will update few more lines after some time. lets have start atleast. :)

December 31st, 2008

This is another example that we have successfully transform old site with new design and some modification on logic.

Old Design

Education and More Site Old Design

Education and More Site Old Design

New Design

Education and more site with new design

Education and more site with new design

Major changes which we have delivered. we have given them paypal integration. with customized puzzles created for them. even admin can approve and disapprove puzzles created by customers.

As they already had admin panel so we have appended new things for them such as managing newletters. and setting letters to subscribers with html formats.

December 19th, 2008

Hello Everyone,

This is really long waiting features on mysql side as well php sides person. that is stored procedure things. I have almost tried all servers. oracle, mssql, msaccess, post gre, mysql. all of them having similar features. just few things are additional or remaining in some of databases.

One best loved things are Stored Procedures.

Q: Why we really need stored procedures ?

A: If you want create big web sites or net applications. all database need to be properly placed. There need to proper seperation of designing layer, application layer. and need to have database layer as seperate entity. I know you might thinking why we need that layer. as I have seen from many years that customer changes their servers as time progresses. and each hosting company giving different price packages. so customer choses their different server. so rather changing the whole application if we have things properly managed on our end then it will be easiest for customer to be independent on server selection.

And Runwalsoft.com is master in doing all code seperation. Stored procedure are pre-compiled sql statements. and basically business logic resides here. so most of the time it is required to change. so let say if some one wants to alter the logic. he will just open stored procedures and alter the changes according to customers need. this makes less disturbances in other code. and where ever you have used the similar function is automatically changed.

In Market generally use normal sql statements in php files. let say project is almost completed and customer have added features to enable or disable depending upon region, Then for this requirement let say we have added such statements in 40 files then we have to change that 40 php files. This takes time on programmer point of view. and generally programmer charge customer for his timing. Though he made wrong design. and he updated only 38 files and forgot to change 2 files. this creates website functioning extremly wrong. visitor of the web sites thinks that creator of the site is fool. or site is worst. and visitor never visit site again. this is lose for site owner.

Now Let say if programmer created database layer seperate. and in that layer if he used stored procedures then for every stored procedure they have used their call on 40 pages. so for changing 1 stored procedure is very small amount of time. inshort this way it will charge less to the customer. and Runwalsoft.com doing same things. we create the system in such a fashion that things are so seperated that it will be easily managable.

Q: As software purchased what they need ?

A : when they are purchasing any hosting company make sure they have mysql5.0 or above and php5.0 or above installed on their server.  if their are lesser version then it will be problem in creating web site. what happen let say if you have lesser version. we have develope that layer (database layer) in traditional old way. so then further changes might cost you more. so sometime its quite better to purchase updated server.

Q: I am programmer how to incorporate stored procedures in php ?

A: I have seen that many people uses phpmyadmin as admin panel for it. so you can use that admin panel to create procedure on that only little difference is that let say if you click on “sql tab” at the bottom of it you will see the box called delimiter to changed “;” to // ( or something other than ; ) and write the following syntax for it.

create procedure showAddition(first decimal(10,2),second decimal(10,2))

begin
select (first + second) as addition;
end

This will create stord procedures. now its time to create page for php. in previous days generally programmer having habit to use mysql normal functions

mysql_connect , mysql_query , mysql_num_rows

But as mysql module doesn’t support stored procedures. you need to installed or need to tell your hosting company to activate mysqli [MySQL Improved Extension] module. this having features to access stored procedures , triggers and many advance fetures which mysql is provided. mysqli technically supports transactional and non transaction databases.

so coming to point.

PHP Code. I am giving you just short code how to access above procedure.

<?php
$mysqli = new MySQLi('localhost','root','root','test') or die("Unable to connect");

$a= 100 ;
$b = 20 ;
// This will fetch results but doesn't show results
$sql = "call showAddition('" . $a ." ','". $b . "');";
if ($mysqli->multi_query($sql)) {
    // This is for first Result ;
    $mysqli->next_result(); // # why this ? *A
    $rs = $mysqli->store_result();
    while($row = $rs->fetch_assoc())
    {
        print_r($row);
    }
}

?>

*A : for accession stored procedures generally mysql sends first response error code. and then it sends output which we have shown. so we have to bypass first resultset.

Another important point is that you need to access mysqli_multi_query function to get multiple results from the database. though there are many different methods. but for the start let have one function working. then I am sure you will become master on it.

Regards

Runwalsoft.com