我正在使用phpredis,现在我也在为我的php应用程序尝试predis,但我找不到第二个的好文档.在github中有一个"如何使用",但我发现它很短.我检查了这些例子,但我注意到他们正在使用"小写"字符中的Redis命令.我尝试了一些并且有效,但我不想尝试所有这些以确定这是否属实......
我正在使用mongodb来存储用户的信息.我想创建一个从db获取信息的方法,创建Player对象并将它们插入到一个Players数组中.
这是以下方法
public ArrayList<Player> getArrayOfPlayers(){
ArrayList<Player> savePlayers = new ArrayList<Player>();
DB db = connectToMongo();
DBCollection coll = db.getCollection("players");
DBCursor cursor = coll.find();
while(cursor.hasNext()) {
String tempName = (String)cursor.next().get("name");
String tempSession = (String)cursor.next().get("session");
String tempStringScore = (String)cursor.next().get("score");
int tempScore = Integer.parseInt(tempStringScore);
Player player = new Player(tempName,tempSession,tempScore);
savePlayers.add(player);
}
return savePlayers;
}
Run Code Online (Sandbox Code Playgroud)
我有4个用户存储在数据库中,当我试图首先调用该方法,然后打印名称,例如我得到一个例外.我在方法之外使用了try-catch,但是我抓住了异常,但之后它只打印了第一个用户的名字.它似乎在第二次迭代中抛出异常.
这是除了我收到的例外的消息.
java.lang.RuntimeException: no more
com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:394)
com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:360)
com.mongodb.DBCursor._next(DBCursor.java:445)
com.mongodb.DBCursor.next(DBCursor.java:525)
machine.DAOMongodb.getArrayOfPlayers(DAOMongodb.java:74)
machine.testDB.doGet(testDB.java:43)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Run Code Online (Sandbox Code Playgroud) 有没有人试过并成功在MAMP上安装gearman扩展?我试图在MAC OS X 10.6.8上的MAMP 2.x上进行
我试图用php preg_replace更改html的所有链接.所有的uris都有以下形式
http://example.com/page/58977?forum=60534#comment-60534
Run Code Online (Sandbox Code Playgroud)
我想将其更改为:
http://example.com/60534
Run Code Online (Sandbox Code Playgroud)
这意味着删除"page"之后和"comment-"之前的所有内容,包括这两个字符串.
我尝试了以下内容,但它没有返回任何更改:
$result = preg_replace("/^.page.*.comment-.$/", "", $html);
Run Code Online (Sandbox Code Playgroud)
但似乎我的正则表达式语法不正确,因为它返回html不变.你能帮帮我吗?