在下面的代码中,IDE会在最后一个括号中提醒我"Missing return statement".这导致我在这里询问内部的返回try{}
是否正常或应该在它之外.
非常感谢.
public function getFileNamesFromKeywords( array $ids, $format ) {
try {
if(self::$dbLink) {
$ids = implode(',',$ids);
$query = 'SELECT d.id, d.wfid, d.docid , k.keyword, k.value'.
'FROM keywords k'.
'INNER JOIN documents d '.
'ON k.document_id = d.id'.
'WHERE k.document_id IN ('.$ids.')';
$results = self::$dbLink->query($query);
if( $results === false ) {
throw new Exception('Ocurrió un error al consultar a la DB.', 500);
}
$results = $results->fetchAll(PDO::FETCH_ASSOC);
$filenames = $this->buildFileNames( $results, $ids, $format );
}
else { …
Run Code Online (Sandbox Code Playgroud) 我从Javascript开始,我写了这个函数:
function disableField() {
if( document.getElementById("valorFinal").length > 0 ) ) {
document.getElementById("cantidadCopias").disabled = true;
}
}
Run Code Online (Sandbox Code Playgroud)
如果填充第一个字段,则禁用名为cantidadCopias的第二个字段.
<label> <span>Valor final:</span>
<input type="text" class="input_text" name="valorFinal" id="valorFinal" onkeydown="disableField()"/>
</label>
<label> <span>Cantidad de Copias:</span>
<input type="text" class="input_text" name="cantidadCopias" id="cantidadCopias"/>
</label>
Run Code Online (Sandbox Code Playgroud)
但是当第一个字段填满时,它不会禁用第二个字段.
在Bash中,我试图使函数getLock与不同的锁名称一起使用.
function getLock
{
getLock_FILE="${1}"
getLock_OP="${2}"
case "${getLock_OP}" in
"LOCK_UN")
flock -u "${getLock_FILE}"
rm -fr "${getLock_FILE}"
;;
"LOCK_EX")
flock -x "${getLock_FILE}"
esac
}
Run Code Online (Sandbox Code Playgroud)
但是弗洛克说 flock: bad number: myfilelock
我怎样才能锁定文件,并在需要时释放它,而不必在flock中执行命令?
它是这样使用的:
getLock myfilelock LOCK_EX
somecommands
........
getLock myfilelock LOCK_UN
Run Code Online (Sandbox Code Playgroud) 有时我有非常大的函数,我觉得很难"压缩"或分成更小的函数,因为函数不会在脚本的任何其他部分使用.
所以,我想对它提出一些建议:我应该创建不会在脚本的其他部分使用的函数,还是应该只在多次使用它们时才创建它们?
谢谢!
摘要:
目前我的职责是:
protected function processScanned()
{
try
{
// EJECUTAR BASH DE NAHUEL
//
//
$PdfCPList = $this->model->getDirFilenames( $this->model->dirCartasPorte, 'pdf' );
$PdfTBList = $this->model->getDirFilenames( $this->model->dirTicketsBalanza, 'pdf' );
$PdfCompList = $this->model->getDirFilenames( $this->model->dirCompletos, 'pdf' );
$PdfUnreconList = $this->model->getDirFilenames( $this->model->dirSinReconocer,'pdf' );
// Adjuntar Novedades
$newsToProcess = $this->model->getDirFilenames( $this->model->dirNovedades, 'txt', true);
$this->appendNewsFiles($newsToProcess);
$report = array();
$report['info'] = array(
'Documentos procesados correctamente'=>0,
'Fecha de última actualización de datos'=>date('d/m/Y H:i:s',(int)file_get_contents($this->model->uriTxtInfo)),
);
if($file = fopen( $this->model->uriTxtProcesar, 'r' ) )
{ …
Run Code Online (Sandbox Code Playgroud) 我有一个html5的视频标签,似乎有一个5px space
视频和它的容器div元素之间.
如果我放入font-size: 0
容器元素(#video-container
),空间就会消失.
我知道这是一个问题display: inline-block
,但我没有那个元素.
此外,尝试下一次关闭后打开标签的解决方案,没有删除空格.
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#wrapper {
width: 100%;
height: 100%;
}
#video-container {
overflow: hidden;
width: 100%;
background: #2c5894;
}
#video-container video {
width: 100%;
}
#turnera-container {
float: right;
width: 250px;
vertical-align: top;
height: 100%;
}
.turno-wrapper {
height: 25%;
display: table;
width: 100%;
}
.turno-wrapper {
background: #727867;
}
.turno {
border: dashed 1px …
Run Code Online (Sandbox Code Playgroud) 我需要知道我应该使用哪种组来对LDAP中的用户进行分组.
我基本上需要函数MemberOf,以获得基于组成员身份的一些权限.
例:
用户1是第1组和第2组的成员.
这些组需要是动态的,如Active Directory.
问题来了,因为我有这些选择:
Samba: Group Mapping
User Group
Generic: Posix Group
对于用户来说也是如此,我应该选择哪一个?
Generic: User Account
Samba: Account
我找不到一个显示差异的好网站,任何链接都将非常感激.
在最佳实践方面,下一个功能(实际上是否有效)是不是很糟糕?
IDE警告我
''这个'的潜在无效用法.检查Javascript'this'是否在同一个闭包或外部内容中.
$(document).on('change', '#select-all', function(){
if( this.checked ) {
$(this).closest('table').find('input[name="row-id"]').each( function() {
this.checked = true; // Here
})
}
else {
$(this).closest('table').find('input[name="row-id"]').each( function() {
this.checked = false; // Here
});
}
});
Run Code Online (Sandbox Code Playgroud)
当我选中带有ID的复选框时select-all
,它会将所有其他选项标记为已选中.
如果我把*放在我的正则表达式中,它就不起作用,如果我放+,它就可以了.
*
应该是0或更多,+
应该是1或更多.
案例*
$num = ' 527545855 ';
var_dump( preg_match( '/\d*/', substr( $num, 0, 18 ), $coincidencias ) );
var_dump($coincidencias);exit;
Run Code Online (Sandbox Code Playgroud)
结果:
int(1)
array(1) {
[0]=>
string(0) ""
}
Run Code Online (Sandbox Code Playgroud)
案例+
$num = ' 527545855 ';
var_dump( preg_match( '/\d+/', substr( $num, 0, 18 ), $coincidencias ) );
var_dump($coincidencias);exit;
Run Code Online (Sandbox Code Playgroud)
结果:
int(1)
array(1) {
[0]=>
string(9) "527545855"
}
Run Code Online (Sandbox Code Playgroud)
我认为两者都应该有效,但我不明白为什么*不起作用.
在哪里记录了这个关键字的存在?(我想这是一个常数,而不是一个对象,对吧?).
无论如何,我想知道它在哪里记录,看看是否还有其他我不了解的关键词.
谢谢