Monday, September 19, 2016

Cross Bowser requrest using JSON in Jquery



$(document).ready(function() {
 var cdbUrl = "http://test-travel-point.com"
 $.getJSON(cdbUrl+"/checkAvailable/searchAvailable",{ 'trvelby': 'bus','seat':'1' }).done(function( res ) {
         retVal=parseInt(res);
         if( retVal>0) {
   $('.errorClass').prepend('Hi! We not having service this place.');
  } else {
   $(userSearchForm).submit();
  }
 });
});

Monday, July 25, 2016

How to Print Array In perl



%metroCity = map { $_ => 1 } qw(MUMBAI HYDERABAD BANGLORE DELHI);
my $myCity = 'HYDERABAD';

if ($metroCity{$myCity}) {
  print " \n\n My City Is: $myCity \n";
}else{
  print " \n\n My City Is not MetroCity \n";    
}

Friday, June 10, 2016

Join in Codeigniter | How to join two tables using Codeigniter

$this->db->select("USER_ID, FNAME, LNAME, CONCAT(FNAME.' '.LNAME) as FULLNAME UI.EMAIL, UI.AGE, UI.GENDER");
$this->db->from('user_info UI');
$this->db->join('user_details UD','UD.USER_ID=UI.USER_ID');
$this->db->where('USER_ID', $userId);
$result = $this->SelCon->get();
return $result->row_array();

Wednesday, June 8, 2016

Basic of AnjularJs | AngularJs with Examples | Two way-data


Two way Data Binding in AngularJS

FirstName :{{fname}} MiddleName : FirstName : MiddleName :

Basic of AnjularJs | AngularJs with Examples | One way-data


one way Data Binding in AngularJS

FirstName :{{fname}} MiddleName :

Wednesday, May 25, 2016

All Mysql JOIN with example.

Note: FULL JOIN doesn't support to Mysql so we can use UNION or UNION ALL
select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed FULL JOIN emp_dseg edesg ON ed.empid = edesg.empid;

mysql> select * from emp_data;
+-------+------------+------------+
| empid | emp_name   | emp_Join   |
+-------+------------+------------+
|     1 | Ajay       | 2015-01-11 |
|     2 | Anji       | 2015-01-05 |
|     3 | Sabhapathi | 2015-11-11 |
|     4 | Bhasker    | 2015-04-11 |
|     5 | Raju       | 2014-01-10 |
|     6 | Mahipal    | 2015-01-15 |
|     7 | Manoj      | 2015-09-14 |
|     8 | Ragvendra  | 2015-06-05 |
|     9 | Sundheer   | 2015-01-09 |
|    10 | Mahi       | 2015-01-1  |
|    11 | Vijay      | 2015-01-05 |
|    12 | Sandip     | 2015-01-1  |
+-------+------------+------------+
12 rows in set (0.00 sec)

mysql> select * from emp_dseg;
+-------+----------------------+
| empid | designation          |
+-------+----------------------+
|     1 | Dev                  |
|     2 | QA                   |
|     3 | Senior Soft Engineer |
|     4 | Dev                  |
|     5 | Qa Engineer          |
|     6 | Dev                  |
|     7 | Dev                  |
|     8 | Senior Test Engineer |
|     9 | Test Eng. Enineer    |
|    13 | IT-Support           |
|    14 | DBA                  |
+-------+----------------------+
11 rows in set (0.00 sec)

mysql> select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed, emp_dseg edesg where ed.empid = edesg.empid;
+-------+------------+------------+----------------------+
| empid | emp_name   | emp_Join   | designation          |
+-------+------------+------------+----------------------+
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
+-------+------------+------------+----------------------+
9 rows in set (0.00 sec)

mysql> select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed INNER JOIN emp_dseg edesg ON ed.empid = edesg.empid;
+-------+------------+------------+----------------------+
| empid | emp_name   | emp_Join   | designation          |
+-------+------------+------------+----------------------+
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
+-------+------------+------------+----------------------+
9 rows in set (0.00 sec)

mysql> select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed RIGHT JOIN emp_dseg edesg ON ed.empid = edesg.empid;
+-------+------------+------------+----------------------+
| empid | emp_name   | emp_Join   | designation          |
+-------+------------+------------+----------------------+
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
|  NULL | NULL       | NULL       | IT-Support           |
|  NULL | NULL       | NULL       | DBA                  |
+-------+------------+------------+----------------------+
11 rows in set (0.00 sec)


mysql> select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed LEFT JOIN emp_dseg edesg ON ed.empid = edesg.empid;
+-------+------------+------------+----------------------+
| empid | emp_name   | emp_Join   | designation          |
+-------+------------+------------+----------------------+
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
|    10 | Mahi       | 2015-01-1  | NULL                 |
|    11 | Vijay      | 2015-01-05 | NULL                 |
|    12 | Sandip     | 2015-01-1  | NULL                 |
+-------+------------+------------+----------------------+
12 rows in set (0.00 sec)

mysql> select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed RIGHT JOIN emp_dseg edesg ON ed.empid = edesg.empid
UNION
select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed LEFT JOIN emp_dseg edesg ON ed.empid = edesg.empid

+-------+------------+------------+----------------------+
| empid | emp_name   | emp_Join   | designation          |
+-------+------------+------------+----------------------+
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
|  NULL | NULL       | NULL       | IT-Support           |
|  NULL | NULL       | NULL       | DBA                  |
|    10 | Mahi       | 2015-01-1  | NULL                 |
|    11 | Vijay      | 2015-01-05 | NULL                 |
|    12 | Sandip     | 2015-01-1  | NULL                 |
+-------+------------+------------+----------------------+
14 rows in set (0.00 sec)

mysql> select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed RIGHT JOIN emp_dseg edesg ON ed.empid = edesg.empid
UNION ALL
select ed.empid, ed.emp_name, ed.emp_Join, edesg.designation from emp_data ed LEFT JOIN emp_dseg edesg ON ed.empid = edesg.empid

+-------+------------+------------+----------------------+
| empid | emp_name   | emp_Join   | designation          |
+-------+------------+------------+----------------------+
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
|  NULL | NULL       | NULL       | IT-Support           |
|  NULL | NULL       | NULL       | DBA                  |
|     1 | Ajay       | 2015-01-11 | Dev                  |
|     2 | Anji       | 2015-01-05 | QA                   |
|     3 | Sabhapathi | 2015-11-11 | Senior Soft Engineer |
|     4 | Bhasker    | 2015-04-11 | Dev                  |
|     5 | Raju       | 2014-01-10 | Qa Engineer          |
|     6 | Mahipal    | 2015-01-15 | Dev                  |
|     7 | Manoj      | 2015-09-14 | Dev                  |
|     8 | Ragvendra  | 2015-06-05 | Senior Test Engineer |
|     9 | Sundheer   | 2015-01-09 | Test Eng. Enineer    |
|    10 | Mahi       | 2015-01-1  | NULL                 |
|    11 | Vijay      | 2015-01-05 | NULL                 |
|    12 | Sandip     | 2015-01-1  | NULL                 |
+-------+------------+------------+----------------------+
23 rows in set (0.00 sec)




INNER JOIN gets all records from one table that have some related or matching records from second table

LEFT JOIN gets all records from the LEFT Side linked table but if you have selected some columns from the RIGHT table, if there is no related records, these columns will contain NULL

RIGHT JOIN is like the above but gets all records in the RIGHT table

FULL JOIN gets all records from both tables and puts NULL in the columns where related records do not exist in the opposite table


Tuesday, May 24, 2016

Cross Platform Requrest in PHP

my $xml = <<"GENERATE_XML";
< GeStdDataInput >
  < Course>BE< /Course>
  < StdName>TestStudent< /StdName>
  < CourseFee>350000
< /GeStdDataInput >
GENERATE_XML

$xmlReq = array (
  'http' => array(
  'method' =>"POST",
         'header' => "Content-Type: application/xml\r\nAccept: application/xml",
         'timeout' => 60,
         'content' => $xml)
 );
 $ulr = 'http://studentrecords.com/getStduentData';
 $strCont = stream_context_create ($xmlReq);
        $filePoint = @fopen($url, 'rb', false, $strCont);
        if (!$filePoint){
  $filePoint = @fopen($url, 'rb', false, $strCont);
  if (!$filePoint) {
                    throw new Exception("Problem with $url, $php_errormsg");
                }
 }
 $response = @stream_get_contents($filePoint);
        $response_array = array();
 $response_array = simplexml_load_string($response);

Cross Platform PHP Requrest

my $xml = <<"GENERATE_XML";

  BE
  TestStudent
  350000

GENERATE_XML

$xmlReq = array (
  'http' => array(
  'method' =>"POST",
         'header' => "Content-Type: application/xml\r\nAccept: application/xml",
         'timeout' => 60,
         'content' => $xml)
 );
 $ulr = 'http://studentrecords.com/getStduentData';
 $strCont = stream_context_create ($xmlReq);
        $filePoint = @fopen($url, 'rb', false, $strCont);
        if (!$filePoint){
  $filePoint = @fopen($url, 'rb', false, $strCont);
  if (!$filePoint) {
                    throw new Exception("Problem with $url, $php_errormsg");
                }
 }
 $response = @stream_get_contents($filePoint);
        $response_array = array();
 $response_array = simplexml_load_string($response);

Cross Platform request using PERL

my $xml = <<"GENERATE_XML";
< gestddatainput >
< course >BE< /Course >
< stdname >TestStudent< /StdName >
< coursefee >350000< /CourseFee >
< /GeStdDataInput >
GENERATE_XML

my $length = length($xml);
my $ua = LWP::UserAgent->new(env_proxy => 1, keep_alive => 1, timeout =>45);
my $req = HTTP::Request->new(POST =>'http://studentrecords.com/getStduentData');
$req->content($xml);
$req->header('Connection' => 'close', 'Content-length' => $length,'Content-Type'=>'text/xml', charset=>'utf-8');
my $res = $ua->request($req);
my $response_data = $res->content;
my $ref;
eval {
$ref =  new XML::Smart($response_data);
};
if($@){
print STDERR "\n------- Student Response START----------";
print STDERR "\n". $response_data;
print STDERR "\n". $@;
print STDERR "\n------- Student Response END----------";
return "";
}
<.pre>

How to Create File in PERL

my $message = "

Wel come to file Handleding

" my $fileName = '/tmp/testUserData.html'; open(my $sqf, '>', $fileName) or die "Could not open file '$fileName' $!"; print $sqf $message; close $sqf;

Monday, May 16, 2016

Create array in Codeigniter model

$tmpHash = array();
foreach ($this->db->get()->result_array() as $row)
{
 $tmpHash[$row['ID']] = $row['ID'];
}
return $tmpHash;


Union Example in Mysql

select * from registration where state in('MH') and taluka in('NANDED','HINGOLI') 
union 
select * from registration where state in('TS') and taluka in('NANDED','KHAIRATABAD','HYDERABAD');

select * from registration where team in('dev') and role_name in(2,3)
union 
select * from registration where team in('it') and role_name in(1,2,3);