Example #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new MySqlDb();
     }
     return self::$instance;
 }
Example #2
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #3
0
 /**
  * create_connection
  *
  * Ahora con manejo de errores.
  * 
  * @author Adrián Méndez <*****@*****.**>
  * @Version 1.2
  */
 protected function create_connection()
 {
     if (isset($this->connectionCfg) && isset($this->defaultConnection)) {
         try {
             parent::__construct($this->connectionCfg[$this->defaultConnection]['host'], $this->connectionCfg[$this->defaultConnection]['user'], $this->connectionCfg[$this->defaultConnection]['password'], $this->connectionCfg[$this->defaultConnection]['name']);
         } catch (Exception $e) {
             echo '<pre>Caught exception: ', $e->getMessage(), "\n</pre>";
         }
     } else {
         die("Faltan parametros de conexión");
     }
 }
Example #4
0
<?php

set_time_limit(-1);
$mysql = new MySqlDb();
$sqlite = new SqLiteDb();
$mysql->CopyDataTo($sqlite);
echo $mysql->GetError();
echo $sqlite->GetError();
$mysql->Close();
$sqlite->Close();
////////////////// Start Class Implementations ///////////////////////
abstract class Db
{
    var $db_res;
    abstract function Query($query);
    abstract function FetchObject($result);
    abstract function FetchArray($result);
    abstract function FetchAssocArray($result);
    abstract function FreeResult($result);
    abstract function GetError();
    abstract function GetTables();
    abstract function GetFields($table_name);
    abstract function EscapeString($string);
    abstract function Close();
    function GetResults($dbres, $use_fetch_method)
    {
        $results = array();
        $reflection = new ReflectionClass($this);
        $ref_method = $reflection->getMethod($use_fetch_method);
        $temp_res;
        while ($temp_res = $ref_method->invoke($this, $dbres)) {
Example #5
0
File: cleaner.php Project: shrz/sig
<?php

require_once 'config.php';
require_once 'utils.php';
require_once 'db.php';
$db = new MySqlDb(DB_HOST, DB_NAME, DB_USER, DB_PASSWORD);
$queryString = 'DELETE FROM ' . DB_TABLE_PREFIX . 'data WHERE ';
$debugOutput = '';
$doesOldSigExist = false;
foreach (glob(SIG_BASEDIR . '*.png') as $filename) {
    if (time() - filemtime($filename) > SIG_TTL) {
        $doesOldSigExist = true;
        // echo "$filename - ".date( 'd M H:i:s', filemtime( $filename ) ). "\n";
        preg_match("#/([\\d]+).png#", $filename, $match);
        if ($match[1] !== '') {
            $queryString .= 'sigId="' . $match[1] . '" OR ';
            $debugOutput .= $match[1] . ', ';
        }
        @unlink($filename);
    }
}
if ($doesOldSigExist) {
    $queryString = substr($queryString, 0, strlen($queryString) - 4);
    $queryResult = $db->Query($queryString);
    if ($queryResult) {
        $debugOutput = 'Cleaner delete sigs:' . $debugOutput;
        SaveForDebug($debugOutput);
    }
} else {
    SaveForDebug('Cleaner doesn\'t found old sigs.');
}
Example #6
0
ini_set('display_errors', '1');
include_once './db/dbconnect.php';
$school_name = $_GET['inpSchoolName'];
$school_type = $_GET['inpSchoolType'];
$school_addrlane1 = $_GET['inpaddrlane1'];
$school_addrlane2 = $_GET['inpaddrlane2'];
$school_city = $_GET['inpcity'];
$school_state = $_GET['inpstate'];
$school_phone = $_GET['inpphone'];
$school_email = $_GET['inpEmail'];
$school_overview = $_GET['inpoverview'];
$school_ann_fees = $_GET['inpAnualFee'];
$format = strtolower($_GET['format']) == 'json' ? 'json' : 'xml';
$result = '';
$link = NULL;
$db = MySqlDb::getInstance();
try {
    $link = $db->connect('localhost', 'root', 'ramesha', 'mydb');
} catch (Exception $e) {
    $result = $e->getMessage();
}
$query = "INSERT INTO school(school_name, school_addr, school_lat, school_lng, school_city, school_state, school_type, school_ann_fees, school_phone, school_email, school_overview, school_imgs_path, school_doa) VALUES ('{$school_name}','{$school_addrlane1} . {$school_addrlane2}', 10.000, 10.000, '{$school_city}', '{$school_state}', '{$school_type}', '{$school_ann_fees}', '{$school_phone}', '{$school_email}', '{$school_overview}', 'file', CURRENT_TIMESTAMP);";
$db->insert($query);
if ($format == 'json') {
    header('Content-type: application/json');
    echo json_encode('Everything is fine..');
} else {
    header('Content-type: application/xml');
    echo '<result>';
    echo '<value>';
    echo 'Data inserted successfully.';
Example #7
0
<?php

/**
 * Created by PhpStorm.
 * User: ab
 * Date: 3/1/2016
 * Time: 11:33 AM
 */
require_once 'MySqlDb.php';
$DB = new MySqlDb('localhost', 'root', '', 'oop');
$result = $DB->query('SELECT * FROM test');
?>
<!DOCTYPE html >
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>

	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

	<!-- Latest compiled and minified JavaScript -->
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container">

	<?php 
foreach ($result as $row) {
    ?>