使用“静态”用于实现Singleton模式的关键字 [英] using the "static" keyword to implement the Singleton pattern
问题描述
要打电话我会做类似的事情:
$ headline = McSelectJustOneField :: callDatastore(" cbHeadline");
是这正确使用了static关键字,来实现一个单独设计的
?
类McSelectJustOneField扩展了McSelect {
/ * *
* 11-21-03 - getter
* @param - $ infoToBeSought,在这种情况下,是该字段的名称
其内容是通缉的。
*返回混合(可以是字符串或整数或
字段中的任何内容)
函数static callDatastore($ infoToBeSought){
$ this-> setQueryObject(" GetJustOneField");
$ this-> setInfoToBeSought($ infoToBeSought);
$ this-> getInfo();
$ row = $ this-> getRowAsArrayWithStringIndex($ this-> dsResultPointer);
$ field = $ row [ 0];
返回$ field;
}
}
To call I would do something like: 这篇关于使用“静态”用于实现Singleton模式的关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
这是否正确使用static关键字来实现
Singleton设计?
级McSelectJustOneField扩展McSelect {
/ **
* 11-21-03 - getter
* @param -
infoToBeSought,在这种情况下,是需要内容的字段
的名称。
*返回混合(可以是字符串或整数或
字段中的任何内容)
函数static callDatastore(
infoToBeSought) {
$headline = McSelectJustOneField::callDatastore("cbHeadline");
Is this the correct use of the static keyword, to implement a
Singleton design?
class McSelectJustOneField extends McSelect {
/**
* 11-21-03 - getter
* @param - $infoToBeSought, in this case, is the name of the field
whose contents are wanted.
* returns mixed (could be string or integer or whatever was in the
field)
function static callDatastore($infoToBeSought) {
$this->setQueryObject("GetJustOneField");
$this->setInfoToBeSought($infoToBeSought);
$this->getInfo();
$row = $this->getRowAsArrayWithStringIndex($this->dsResultPointer);
$field = $row[0];
return $field;
}
}headline = McSelectJustOneField::callDatastore("cbHeadline");
Is this the correct use of the static keyword, to implement a
Singleton design?
class McSelectJustOneField extends McSelect {
/**
* 11-21-03 - getter
* @param -infoToBeSought, in this case, is the name of the field
whose contents are wanted.
* returns mixed (could be string or integer or whatever was in the
field)
function static callDatastore(infoToBeSought) {