//function to check if the request is made through ajax
function isAjax() {
return (isset($_SERVER['HTTP_X_
($_SERVER['HTTP_X_REQUESTED_
}
}
A self-motivated, multi-domain, hardworking, responsible and solutions-orientated JAVA, J2EE, Spring 4, HTML 5, CSS 3, JavaScript, ES6, Typescript, AngularJS 1.4, jQuery 1.8, PHP 5, Shell Script, PL SQL, MySQL, Google App Engine, Google Datastore, JPA, Cucumber BDD Professional with more then 8+ Years of IT experience in a various IT stages including Design, developing, Unit testing and enhancement and 24*7 support application.
Configure HTML/JavaScript
Monday, December 20, 2010
Checking the Request is Ajax
Thursday, December 9, 2010
managing multiple Databases in php
Hi,
This is important to manage your database connections in php if you are using many connections in a single application. you can use single ton pattern in php to make is clear.
Exe:
class Connector {
private $conn;
private $intranetdb = 'jprod';
private $metricsdb = 'metrics_prod';
private function __costructor(){
}
static function intranetDb(){
return 'jprod';
}
static function metricsDb(){
return 'metrics_prod';
}
static function makeConnection($host, $username, $password){
return $this->conn = mysql_connect($host, $username, $password);
}
static function prodConnection(){
$prod_dbhost = 'localhost1';
$prod_dbuser = 'jroot';
$prod_dbpass = 'joomla1';
/*
$prod_dbhost = 'localhost';
$prod_dbuser = 'root';
$prod_dbpass = '';
*/
$prod_conn = mysql_connect($prod_dbhost, $prod_dbuser, $prod_dbpass) or die ('Error connecting to mysql');
return $prod_conn;
}
static function metricsConnection(){
$dbhost = 'localhost2';
$dbuser = 'jroot';
$dbpass = 'joomla1';
/*
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
*/
$db = 'metrics_prod';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
return $conn;
}
static function closeConnection($resource){
return mysql_close($resource);
}
static function freeResult($result){
return mysql_free_result($result);
}
}
private $conn;
private $intranetdb = 'jprod';
private $metricsdb = 'metrics_prod';
private function __costructor(){
}
static function intranetDb(){
return 'jprod';
}
static function metricsDb(){
return 'metrics_prod';
}
static function makeConnection($host, $username, $password){
return $this->conn = mysql_connect($host, $username, $password);
}
static function prodConnection(){
$prod_dbhost = 'localhost1';
$prod_dbuser = 'jroot';
$prod_dbpass = 'joomla1';
/*
$prod_dbhost = 'localhost';
$prod_dbuser = 'root';
$prod_dbpass = '';
*/
$prod_conn = mysql_connect($prod_dbhost, $prod_dbuser, $prod_dbpass) or die ('Error connecting to mysql');
return $prod_conn;
}
static function metricsConnection(){
$dbhost = 'localhost2';
$dbuser = 'jroot';
$dbpass = 'joomla1';
/*
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
*/
$db = 'metrics_prod';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
return $conn;
}
static function closeConnection($resource){
return mysql_close($resource);
}
static function freeResult($result){
return mysql_free_result($result);
}
}
Subscribe to:
Posts (Atom)