我在比较MySQL数据库的写性能方面比较了node.js和PHP.我使用Apache的基准,Linux Mint的虚拟机,最新的MySQL服务器(43年5月5日)和驱动程序为MySQL与node.js的从这里开始.我用的代码是
server.js
var http = require('http');
var mysql = require('mysql');
var server = http.createServer(function (req, res) {
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
database : 'testDB'
});
connection.connect();
connection.query("INSERT INTO Persons (LastName, FirstName, Address, City) VALUES ('Futterkiste', 'Alfreds', 'Obere Str. 57', 'Berlin')", function(err, rows, fields) {
if (!err)
console.log('The solution is: ', rows);
else
console.log('Error while performing Query.');
});
connection.end();
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World');
});
server.listen(1337, '127.0.0.1');
console.log('Server running …Run Code Online (Sandbox Code Playgroud) 我是新来的代码文档,并试图用grunt-ngdocs记录我的角度应用程序.
我从以下网址克隆了一个工作示例:https://github.com/m7r/grunt-ngdocs-example
给定的示例缺少文档控制器,因此我使用以下代码添加了自己的文档控制器:
/**
* @ngdoc controller
* @name rfx.controller:testCtrl
* @description
* Description of controller.
*/
.controller('testCtrl', function() {
});
Run Code Online (Sandbox Code Playgroud)
当我尝试通过从命令行运行grunt来构建文档时,我收到以下错误消息:
Warning: Don't know how to format @ngdoc: controller Use --force to continue.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?我阅读了本指南http://www.shristitechlabs.com/adding-automatic-documentation-for-angularjs-apps/,如果我尝试记录控制器,我无法弄清楚为什么我会不断收到错误消息:(谢谢任何帮助!
javascript documentation-generation angularjs ngdoc grunt-ngdocs
我正在编写angularjs应用程序,它依赖于从MySQL数据库返回的数据.
Angularjs代码发出HTTP请求并将返回的数据记录到控制台:
$http({method: 'POST', url: 'php/return_something.php', headers: {'Content-Type': 'application/json'}})
.success(function(data, status, headers, config) {
//The API call to the back-end was successful (i.e. a valid session)
console.log(data);
})
.error(function(data, status, headers, config) {
console.log("Error.");
});
Run Code Online (Sandbox Code Playgroud)
return_something.php
try
{
$conn = new PDO("mysql:host=".DB_HOST."; dbname=".DB_DATABASE, DB_USER, DB_PASSWORD);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = $conn->prepare("SELECT count(id_table_x) from table_x; SELECT count(id_table_y) from table_y;");
$sql->execute();
// set the resulting array to associative
$results = $sql->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results);
}
catch(PDOException …Run Code Online (Sandbox Code Playgroud) angularjs ×2
php ×2
benchmarking ×1
database ×1
grunt-ngdocs ×1
http ×1
javascript ×1
mysql ×1
ngdoc ×1
node.js ×1
select ×1