Follow by Email

Monday, September 8, 2014

Creating Restful Services/API using the Slim Framework for PHP || Calling API using Jquery

I was trying to create Rest Api using PHP , then i came across this Slim framework for php, which lets us create powerful APIs.

This below link shows how to create RESTful API using Slim framework and also how to call that api using Jquery.

Friday, September 5, 2014

PHP :: calling from one controller action method to another controller action method

hi in this post i will show how to call from one controller action method to another controller action method 

Code:

class Welcome extends CI_Controller {

public function index()
{
   if(1==1) 
            {
              $this->fcTest(); //calling another method
            }
            else
            {
              $this->fcTest2();  //calling another method
            }
               
}
        
        public function fcTest()
{
$this->load->view('welcome_message');
}
        
        public function fcTest2()
{
$this->load->view('welcome_message2');
}
     }

Php Codeigniter :: calling controller function from view button click using Jquery AJAX

Hi in this post i will how to call a controller action method from view. In view button click event we will make a ajax call to controller method.

View :

<HTML>
<HEAD>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function AjaxCall(){
$.ajax({
type: "post",
url: "http://localhost/phpProj/index.php/usercontroller/method1",
cache: false,
data: $('#userForm').serialize(),
success: function(json){
try{
var obj = jQuery.parseJSON(json);
alert( obj['STATUS']);


}catch(e) {
alert('Exception while request..');
}
},
error: function(){
alert('Error while request..');
}
 });
}
</script>
</HEAD>
<BODY>
<form name="userForm" id="userForm" action="">
<table border="1">
<tr>
<td valign="top" align="left">
Username:- <input type="text" name="userName" id="userName" value="">
</td>
</tr>
<tr>
<td valign="top" align="left">
Password :- <input type="password" name="userPassword" id="userPassword" value="">
</td>
</tr>
<tr>
<td>
<input type="button" onclick="javascript:AjaxCall();" value="Submit"/>
</td>
</tr>
</table>
</form>
 </BODY>
</HTML>

Controller:

class usercontroller extends CI_Controller {

  public function method1() {
$userName =  $_POST['userName'];
$userPassword =  $_POST['userPassword'];
$status = array("STATUS"=>"false");
if($userName=='admin' && $userPassword=='admin'){
$status = array("STATUS"=>"true");
}
echo json_encode ($status) ;

}


}


Monday, September 1, 2014

Microsoft SQL Server vs. MySQL vs. Oracle Comparison

Hi below is the comparison of the Top 3 Widely Used Databases around the Globe :

Basic Highlights :

1. Microsoft SQL Server : 

Pros:

  • Rich GUI
  • Great Performance
  • Easy to Use
  • Built-in BI Tools
  • Works well with .Net

Cons:

  • Free Version Supports only 10 GB of Database
  • The Paid Version is costly


2. MySql

Pros:

  • Free 
  • Works well with PHP
  • Large Community
  • Runs on Any OS


Cons:

  • no built in tools
  • Sometimes troubleshoot consumes more time due to lack to tools
  • Features are less compared to Oracle and Sql Server


3. Oracle

Pros :

  • Everything is under Transaction, so need to commit every-time
  • Runs on Any OS
  • Works well with Java
  • Good on Performance, Highly Scalable

Cons:

  • GUI is not that great compared to MS Sql Server
  • Expensive
  • More configuration


Detailed Comparison:

Microsoft SQL Server vs. MySQL vs. Oracle Comparison