我正在尝试在code.google.com上使用NameCase php类.当我运行它时,我得到了这个通知,我不明白为什么.
PHP注意:使用未定义的常量Mc - 在namecase.php中假设'Mc'(54):第1行的regexp代码
53 if( preg_match('/\bMac[A-Za-z]{2,}[^aciozj]\b/', $str) || preg_match('/\bMc/', $str) ) {
54 $str = preg_replace("/\b(Ma?c)([A-Za-z]+)/e", "$1.ucfirst('\\2')", $str);
55 // Now correct for "Mac" exceptions
56 $str = preg_replace('/\bMacEvicius/','Macevicius', $str); // Lithuanian
57 $str = preg_replace('/\bMacHado/', 'Machado', $str); // Portuguese
58 $str = preg_replace('/\bMacHar/', 'Machar', $str);
59 ...
Run Code Online (Sandbox Code Playgroud)
有没有什么可以做的纠正代码,所以它不会产生通知.
谢谢
数据库中有一个用户,应该重命名该用户.如何重命名用户?MongoDB用户管理引用具有方法db.updateUser但我没有看到如何为用户设置新名称.如何更新用户名?TY
db.updateUser(
"<username>",
{
customData : { <any information> },
roles : [
{ role: "<role>", db: "<database>" } | "<role>",
...
],
pwd: "<cleartext password>"
},
writeConcern: { <write concern> }
)
Run Code Online (Sandbox Code Playgroud) 如何使用MongoDB shell定义函数并使用它?
在脚本文件中,createusers.js有以下代码用于创建在特定数据库上具有读取角色的用户.
function createReader(database, username, password)
{
db.getSiblingDB(database).createUser({
user : username,
pwd : password,
roles : [ { role : "read", db : database } ]
});
}
Run Code Online (Sandbox Code Playgroud)
是否有可能在mongodb shell中执行此功能?以下调用不成功
mongo --eval="createReader('somedb', 'user1', 'pass1')" createusers.js
给出错误createReader没有定义.
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何打印消息bMethod吗?
我有一个数组(18键):
$en = array(
'?' => 'A',
'?' => 'C',
'?' => 'E',
'?' => 'E',
'?' => 'I',
'Š' => 'S',
'?' => 'U',
'?' => 'U',
'Ž' => 'Z',
'?' => 'a',
'?' => 'c',
'?' => 'e',
'?' => 'e',
'?' => 'i',
'š' => 's',
'?' => 'u',
'?' => 'u',
'ž' => 'z',
);
Run Code Online (Sandbox Code Playgroud)
这些键是立陶宛simbols(utf8编码).当我这样做$lt = array_flip($en);时返回以下内容:
Array
(
[A] => ?
[C] => ?
[E] => ?
[I] => ?
[S] => …Run Code Online (Sandbox Code Playgroud) 我有以下代码.我不确定如何安排它们,以便它可以在将记录添加到SQL数据库之前检查CSV中的条目.问题是我仍然在sql中添加双重记录
try {
br = new BufferedReader(new FileReader(file));
String[] data1 = br.readLine().split(cvsSplitBy);
while ((line = br.readLine()) != null) {
String queryCheck = "SELECT Count(Name) from DB WHERE Name = ?";
PreparedStatement st = conn.prepareStatement(queryCheck);
//value is the data of the name column in the CSV
st.setString(1, data1[0]);
ResultSet rs = st.executeQuery();
boolean recordFound = rs.next();
if (recordFound) {
//dont add record
System.out.println("found " + data1[0]);
} else {
String[] data = line.split(cvsSplitBy);
String sql2 = "INSERT INTO DB (Name, ID, …Run Code Online (Sandbox Code Playgroud) 在Java的包中java.util.concurrent.atomic AtomicInteger类有一个方法addAndGet(int)
是的
public final int addAndGet(int delta) {
for (;;) {
int current = get();
int next = current + delta;
if (compareAndSet(current, next))
return next;
}
}
Run Code Online (Sandbox Code Playgroud)
为什么它在这里使用无限循环来设置值?
在选择中,我使用了这样的 array_to_string(示例)
array_to_string(array_agg(tag_name),';') tag_names
Run Code Online (Sandbox Code Playgroud)
我得到了结果字符串,"tag1;tag2;tag3;..."但我想将结果字符串作为"'tag1';'tag2';'tag3';...".
我怎样才能在 Postgres 中做到这一点?
我有一个用于服务隔离场景的服务 SoundPanelService(例如https://angular.io/guide/hierarchical-dependency-injection#scenario-service-isolation)
@Injectable()
export class SoundPanelService {
recorded = new Subject<Sound>();
constructor() {
}
}
Run Code Online (Sandbox Code Playgroud)
我有 SoundPanelComponent
Component({
selector: 'app-sound-panel',
templateUrl: './sound-panel.component.html',
styleUrls: ['./sound-panel.component.css'],
providers: [SoundPanelService] // Service isolation
})
export class SoundPanelComponent implements OnInit {
recorded = new Subject<Sound>();
constructor(private soundPanelService: SoundPanelService) {
this.soundPanelService.recorded.subscribe((data) => {
this.recorded.next(data);
});
}
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
sound-panel.component.html
<app-sound-player></app-sound-player>
<app-sound-recorder></app-sound-recorder>
Run Code Online (Sandbox Code Playgroud)
SoundPlayer 和 SoundRecorder 通过服务 SoundPanelService 与 soundpanel 通信。
我想测试 SoundPanelComponent
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By …Run Code Online (Sandbox Code Playgroud)