在Objective-C实例中,数据可以是public,protected或private.例如:
@interface Foo : NSObject
{
@public
int x;
@protected:
int y;
@private:
int z;
}
-(int) apple;
-(int) pear;
-(int) banana;
@end
Run Code Online (Sandbox Code Playgroud)
我没有在Swift参考中找到任何访问修饰符.是否可以限制Swift中数据的可见性?
所有Hapi示例(以及Express中的类似示例)都显示路由在起始文件中定义:
var Hapi = require('hapi');
var server = new Hapi.Server();
server.connection({ port: 8000 });
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply('Hello, world!');
}
});
server.route({
method: 'GET',
path: '/{name}',
handler: function (request, reply) {
reply('Hello, ' + encodeURIComponent(request.params.name) + '!');
}
});
server.start(function () {
console.log('Server running at:', server.info.uri);
});
Run Code Online (Sandbox Code Playgroud)
但是,在实现具有大量不同路由的生产应用程序时,不难想象这个文件有多大.因此,我想分解路由,将它们分组并存储在单独的文件中,如UserRoutes.js,CartRoutes.js,然后将它们附加到主文件中(添加到服务器对象).您如何建议将其分开然后添加?
我想将逗号作为分隔符字符串加入MySQL中的集合中返回的结果.
例如,set return包含:
COLUMN_X
john
jerry
maria
joseph
gugla
Run Code Online (Sandbox Code Playgroud)
我想收到的结果是:
COLUMN_X-concat
john,jerry,maria,joseph,gugla
Run Code Online (Sandbox Code Playgroud)
那可能吗?谢谢.
SELECT CONCAT(rooms.ID,",") FROM rooms AS rooms LEFT JOIN inter AS i ON rooms.ID=i.value WHERE xxx=999
Run Code Online (Sandbox Code Playgroud)
不起作用,因为它返回单独的结果.
我确信很多人都会问这个问题,但当我检查答案时,在我看来,我发现它们是错误的
var startDate = new Date(Date.parse(startdate));
//The start date is right lets say it is 'Mon Jun 30 2014 00:00:00'
var endDate = new Date(startDate.getDate() + 1);
// the enddate in the console will be 'Wed Dec 31 1969 18:00:00' and that's wrong it should be 1 july
Run Code Online (Sandbox Code Playgroud)
我知道.getDate()从1-31返回但是浏览器或javascript只增加了一天没有更新月份和年份?
在这种情况下,我应该写一个算法来处理这个?还是有另一种方式?
我收到以下C++错误:
array must be initialized with a brace enclosed initializer
Run Code Online (Sandbox Code Playgroud)
从这一系列的C++
int cipher[Array_size][Array_size];
Run Code Online (Sandbox Code Playgroud)
这里有什么问题?错误是什么意思?以下是完整代码:
string decryption(string todecrypt)
{
int cipher[Array_size][Array_size] = 0;
string ciphercode = todecrypt.substr(0,3);
todecrypt.erase(0,3);
decodecipher(ciphercode,cipher);
string decrypted = "";
while(todecrypt.length()>0)
{
string unit_decrypt = todecrypt.substr(0,Array_size);
todecrypt.erase(0,Array_size);
int tomultiply[Array_size]=0;
for(int i = 0; i < Array_size; i++)
{
tomultiply[i] = int(unit_encrypt.substr(0,1));
unit_encrypt.erase(0,1);
}
for(int i = 0; i < Array_size; i++)
{
int resultchar = 0;
for(int j = 0; j<Array_size; j++)
{
resultchar += tomultiply[j]*cipher[i][j];
}
decrypted …Run Code Online (Sandbox Code Playgroud) 我正在从PHP女巫生成JSON响应,如下所示:
{ done:'1', options: [{ message:'Example message'},{message:'This is the 2nd example message'}]}
Run Code Online (Sandbox Code Playgroud)
我想使用ExtJS获取这些结果.这是我到目前为止:
Ext.Ajax.request({
loadMask: true,
url: 'myfile.php',
params: {id: "1"}
});
Run Code Online (Sandbox Code Playgroud)
接下来我要写什么才能得到像这样的json结果:
var mymessages = jsonData.options;
Run Code Online (Sandbox Code Playgroud)
mymessages应该包含Example消息,这是第二个示例消息.
谢谢.
我有两张桌子.
cities - id_city, city_name
properties - id_property, id_city, property_name
Run Code Online (Sandbox Code Playgroud)
我想显示cities.city_name它旁边[properties.count(id_city)]
如果没有找到记录,如何使查询仍返回零NULL,以便得到如下结果:
London [123]
New York [0]
Berlin [11]
Run Code Online (Sandbox Code Playgroud)
"纽约"是[0],NULL不是1而不是1?
我刚刚升级到Mongo 2.6.1,之前正在运行的一个更新语句没有返回错误.更新声明是:
db.post.update( { 'answers.comments.name': 'jeff' },
{ '$set': {
'answers.$.comments.$.name': 'joe'
}},
{ multi: true }
)
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
WriteResult({
"nMatched" : 0,
"nUpserted" : 0,
"nModified" : 0,
"writeError" : {
"code" : 2,
"errmsg" : "Too many positional (i.e. '$') elements found in path 'answers.$.comments.$.createUsername'"
}
})
Run Code Online (Sandbox Code Playgroud)
当我更新一个元素只有一个深度而不是两个(即answers.$.name代替answers.$.comments.$.name),它工作正常.如果我将我的mongo实例降级到2.6以下,它也可以正常工作.
我很确定我已经在某个地方见过这个,但我找不到合适的术语,所以我遇到了麻烦......
假设我有一个包含用户信息的表(让我们假设它是由比我更多付费的人创建的,因此修改模式不是一种选择.)用户信息的各个列中有DOB和职称的列.我想要一个查询,根据这些列中的内容,将包含一个名为"Real_Title"的额外列,例如:
User_id Job_Title DOB
joe_1 manager 01/01/1950
jim_1 associate 01/01/1970
jill_1 associate 01/01/1985
jane_1 manager 01/01/1975
Run Code Online (Sandbox Code Playgroud)
查询:
SELECT User_id, Real_Title FROM users
IF (YEAR(DOB) < 1980 AND Job_Title = "manager")
{Real_Title = "Old Fart"}
ELSE IF (YEAR(DOB) < 1980 AND Job_Title = "associate")
{Real_Title = "Old Timer"}
ELSE IF (YEAR(DOB) > 1980 AND Job_Title = "manager")
{Real_Title = "Eager Beaver"}
ELSE IF (YEAR(DOB) > 1980 AND Job_Title = "associate")
{Real_Title = "Slacker"}
Run Code Online (Sandbox Code Playgroud)
我知道上面的内容不仅错误,而且编码效率也非常低,但我想把这个想法贯穿其中.
有没有一种方法,不使用连接,根据同一个表中一个或多个其他列中的信息填充列?
目前我在获取结果后在PHP脚本中使用了一些东西来将这些结果引导到我想要的组中,但如果可以在查询中完成,那么将查询移植到其他脚本和语言会更容易.
谢谢!
我们正在开发一个node.js Hapi服务器,该服务器从MongoDB数据库中提取路由列表并设置所述路由以进行服务.这样,由于数据库中的路由条目重复,服务器可能会失败.
我试过看,但未能找到一种方法来检查Hapi中的重复路线.
是否有可能获得Hapi服务器当前服务的路由列表?
在尝试构建来自MongoDB的路由时,是否可以进行错误检查,使其比标准的try/catch块更漂亮?
设置路线的代码如下; 请在我需要处理错误的代码中查看我的注释.
MySchema.find({}, function (err, stubs) {
if (err) {
console.log('error while loading');
return;
}
for (var i = 0; i < stubs.length; i++) {
var bodyMessage = stubs[i].body;
// This is where we can fail, if only I could make a
// check for the route here
server.route({
method: stubs[i].method,
path: stubs[i].path,
handler: function (request, reply) {
reply(bodyMessage);
}
});
}
});
Run Code Online (Sandbox Code Playgroud)