error() public method

public error ( )
Exemplo n.º 1
0
 protected function throwMysqlError()
 {
     $errorMsg = "MySQL error occurred. ";
     if (EMA_DEBUG === true) {
         $errorArray = $this->dbConnection->error();
         $errorMsg .= " Debug Data:  " . $errorArray[2];
     }
     throw new \Exception($errorMsg, 6022);
 }
Exemplo n.º 2
0
 /**
  * @return array
  */
 public function error()
 {
     $rt = array('write' => $this->_writer->error(), 'read' => NULL);
     if (empty($this->_reader)) {
         $rt['read'] = $rt['write'];
     } else {
         $rt['read'] = $this->_reader->error();
     }
     return $rt;
 }
Exemplo n.º 3
0
 public function getAjaxMethods()
 {
     $whereClause = $this->getRPCWhere($this->currentClass);
     $dbData = $this->dbQuery(array('AND' => $whereClause));
     if (is_array($dbData) === false) {
         $errorMsg = "Cannot get data from db.";
         if (EMA_DEBUG === true) {
             $errorArray = $this->dbConnection->error();
             $errorMsg .= " Debug Data:  " . $errorArray[2];
         }
         throw new FatalError($errorMsg, 6022);
     }
     if (count($dbData) === 0) {
         return false;
     }
     $methodsArray = array();
     foreach ($dbData as $method) {
         $methodsArray[] = $method['methodName'];
     }
     return $methodsArray;
 }
Exemplo n.º 4
0
ini_set('display_errors', 'ON');
error_reporting(E_ALL);
header("Content-type:text/html;charset=utf-8");
defined('ROOT_PATH') or define('ROOT_PATH', dirname(__FILE__));
include ROOT_PATH . '/../lib/medoo.php';
include ROOT_PATH . '/../lib/Curl.php';
$db = new medoo(array('database_type' => 'mysql', 'database_name' => 'fayuan', 'server' => 'localhost', 'username' => 'root', 'password' => '123456', 'port' => 3306, 'charset' => 'utf8', 'option' => array(PDO::ATTR_CASE => PDO::CASE_NATURAL)));
$curl = new Curl();
$id = 2250;
while ($id <= 1239000) {
    $url = "http://shixin.court.gov.cn/detail?id={$id}";
    $resArr = getHtml($url);
    echo "{$id}\r\n";
    if (is_array($resArr) && !empty($resArr)) {
        //判断数据是否存在
        print_r($resArr);
        $i = $db->insert('shixin', $resArr);
        if ($i <= 0) {
            print_r($db->error());
            die;
        }
    }
    $id++;
}
function getHtml($url)
{
    global $curl;
    $curl->setUrl($url);
    $html = $curl->run();
    return json_decode($html, true);
}
Exemplo n.º 5
0
<?php

// phpinfo();
require 'vendor/autoload.php';
$db = new medoo(['database_type' => 'mysql', 'database_name' => 'test', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL]]);
$r = $db->insert("user", []);
var_dump($r);
var_dump($db->log());
var_dump($db->error());
Exemplo n.º 6
0
<?php

require_once '../vendor/autoload.php';
echo "Hello World";
$file = '../storage/database.db';
if (is_writable('../storage/database.local.db')) {
    $file = '../storage/database.local.db';
}
$database = new medoo(['database_type' => 'sqlite', 'database_file' => '../storage/database.db']);
$comment = new SitePoint\Comment($database);
$comment->setEmail('*****@*****.**')->setName('Bruno Skvorc')->setComment('It works!')->setComment('Hooray! Saving comments works!')->save();
dump($database->error());
?>

<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link rel="apple-touch-icon" href="apple-touch-icon.png">
        <!-- Place favicon.ico in the root directory -->

        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css">
        <script src="js/vendor/modernizr-2.8.3.min.js"></script>
    </head>
    <body>
Exemplo n.º 7
0
<?php

defined("TEMPLATES_PATH") or define("TEMPLATES_PATH", realpath(dirname(__FILE__) . '/view'));
defined("LIBRARY_PATH") or define("LIBRARY_PATH", realpath(dirname(__FILE__) . '/lib'));
include LIBRARY_PATH . '/medoo.min.php';
if (isset($_GET['install']) and !file_exists(LIBRARY_PATH . '/database.db') and isset($_POST['username']) and isset($_POST['pwd']) and isset($_POST['rpt']) and $_POST['pwd'] == $_POST['rpt']) {
    $db = new medoo(LIBRARY_PATH . '/database.db');
    $db->query("CREATE TABLE users (username TEXT,password TEXT);");
    $db->query("CREATE TABLE settings (setting TEXT,value TEXT);");
    $db->query("CREATE TABLE hosts (domain TEXT,checkInTime TEXT,description TEXT);");
    $db->insert("users", ["username" => strtolower($_POST['username']), "password" => password_hash($_POST['pwd'], PASSWORD_DEFAULT)]);
    $db->insert("settings", ["setting" => "secretKey", "value" => rand()]);
    if (!$db->error()[0] == "00000") {
        unlink(LIBRARY_PATH . '/database.db');
        $noticeMessage = "An error occurred while saving the database.";
    } else {
        $noticeMessage = "Successfully installed DropPoint control. Please login.";
    }
}
if (!file_exists(LIBRARY_PATH . '/database.db')) {
    include TEMPLATES_PATH . '/setup.php';
    exit;
}
$db = new medoo(LIBRARY_PATH . '/database.db');
$secretCode = $db->get("settings", "value", ["setting" => "secretKey"]);
function dbHasError()
{
    global $db;
    if ($db->error()[0] == "00000") {
        return false;
    } else {
Exemplo n.º 8
0
        $app->render(200, ['line' => $line]);
    }
});
// Delete Invoice
$app->delete('/api/invoices/:id', 'APIrequest', function ($id) use($app) {
    // Connect
    global $dbCredentials;
    $database = new medoo($dbCredentials);
    // Insert
    $database->delete('invoice', ['id' => $id]);
    $error = $database->error();
    if ($error[1]) {
        $app->render(500, ['error' => true, 'message' => $error[2], 'query' => $database->last_query()]);
    } else {
        $app->render(200, ['message' => 'deleted']);
    }
});
// Delete Invoice Line
$app->delete('/api/invoices/:invoice_id/lines/:line_id', 'APIrequest', function ($invoice_id, $line_id) use($app) {
    // Connect
    global $dbCredentials;
    $database = new medoo($dbCredentials);
    // Insert
    $database->delete('line', ['AND' => ['id' => $line_id, 'invoice_id' => $invoice_id]]);
    $error = $database->error();
    if ($error[1]) {
        $app->render(500, ['error' => true, 'message' => $error[2], 'query' => $database->last_query()]);
    } else {
        $app->render(200, ['message' => 'deleted']);
    }
});