last_query() public method

public last_query ( )
Example #1
0
 /**
  * @return array
  */
 public function last_query()
 {
     $rt = array('write' => $this->_writer->last_query(), 'read' => NULL);
     if (empty($this->_reader)) {
         $rt['read'] = $rt['write'];
     } else {
         $rt['read'] = $this->_reader->last_query();
     }
     return $rt;
 }
 */
echo "_______________\n";
$database = new medoo('meetingmanage');
print_r($database->info());
/*
 * 查看错误信息
 */
echo "_______________\n";
$database->select("bccount", array("user_name", "email"), array("user_id[<]" => 20));
var_dump($database->error());
/*
 * 查看上一条query
 */
echo "_______________\n";
$last_user_id = $database->insert("test", array("user" => "fooa", "email" => "*****@*****.**", "id" => 25, "pwd" => "smart", "name" => array("en", "fr", "jp", "cn")));
echo $database->last_query();
/*
 * quote函数,单引号
 */
echo "_______________\n";
$data = "Medoo";
echo "we love" . $data . "\n";
echo "we love" . $database->quote($data);
/*
 * query()函数
 */
echo "_______________\n";
$data1 = $database->query("select * from test")->fetchAll();
print_r($data1);
/*
 * where的使用
        $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']);
    }
});