本文整理汇总了PHP中self类的典型用法代码示例。如果您正苦于以下问题:PHP self类的具体用法?PHP self怎么用?PHP self使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了self类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEliteFour
public static function getEliteFour($where = null, $limit = null, $order = ' e.`order`, e.`id` ')
{
if (!is_null($where)) {
$where = 'WHERE ' . $where;
}
$getEliteFour = TPP::db()->query("SELECT\n\t\t\te.`id`,\n\t\t\te.`name`,\n\t\t\te.`type`,\n\t\t\te.`attempts`,\n\t\t\te.`wins`,\n\t\t\te.`losses`,\n\t\t\te.`time`,\n\t\t\te.`is_rematch`,\n\t\t\te.`order`,\n\t\t\tGROUP_CONCAT(\n\t\t\t\tDISTINCT CONCAT_WS('" . self::SEPARATOR_2 . "',\n\t\t\t\t\tefp.`id`,\n\t\t\t\t\tefp.`pokemon`,\n\t\t\t\t\tefp.`level`\n\t\t\t\t) SEPARATOR '" . self::SEPARATOR_1 . "'\n\t\t\t) as `pokemon`,\n\t\t\tGROUP_CONCAT(\n\t\t\t\tDISTINCT CONCAT_WS('" . self::SEPARATOR_2 . "',\n\t\t\t\t\tefpm.elite_four_pokemon_id,\n\t\t\t\t\tefpm.name\n\t\t\t\t) SEPARATOR '" . self::SEPARATOR_1 . "'\n\t\t\t) as `moves`\n\t\t\tFROM `elite_four` e\n\t\t\tJOIN `elite_four_pokemon` efp\n\t\t\t\tON efp.`elite_four_id` = e.`id`\n\t\t \tLEFT JOIN `elite_four_pokemon_move` efpm\n\t\t \t\tON efpm.`elite_four_pokemon_id` = efp.`id`\n\t\t\t" . $where . "\n\t\t\tGROUP BY e.`id`\n\t\t\tORDER BY " . $order . $limit);
if (!$getEliteFour) {
return [];
}
$return = [];
$beaten = $count_e4 = 0;
while ($eliteFour = $getEliteFour->fetch()) {
$count_e4++;
if (isset($eliteFour['time']) && $eliteFour['time'] != '') {
$beaten++;
}
$newE4 = new self();
$newE4->setAttributes(['id' => (int) $eliteFour['id'], 'name' => $eliteFour['name'], 'type' => $eliteFour['type'], 'attempts' => (int) $eliteFour['attempts'], 'wins' => (int) $eliteFour['wins'], 'losses' => (int) $eliteFour['losses'], 'time' => $eliteFour['time'], 'order' => (int) $eliteFour['order'], 'is_rematch' => (bool) $eliteFour['is_rematch'], 'pokemon' => parent::getPokemonForTrainer($eliteFour['pokemon'], ['id', 'pokemon', 'level'])]);
$moves = [];
foreach (explode(self::SEPARATOR_1, $eliteFour['moves']) as $move) {
$ex = explode(self::SEPARATOR_2, $move);
$moves[$ex[0]][] = $ex[1];
}
foreach ($newE4->pokemon as $p) {
if (isset($moves[$p->id])) {
$p->moves = $p->setMoves($moves[$p->id]);
}
}
$return[] = $newE4;
}
return ['beaten' => $beaten === $count_e4, 'elitefour' => $return];
}
示例2: includeTemplate
/**
*
* @param unknown_type $template
* @param unknown_type $data
* @return string
*/
protected function includeTemplate($template, $data = null)
{
$view = new self();
$view->setTemplate($template);
$view->copyAll($data);
return $view->render();
}
示例3: generateRelatedSymptom
/**
* @param array $symptoms
* @param array $exclusions
* @return string
*/
public static function generateRelatedSymptom(array $symptoms, array $exclusions = array())
{
$instance = new self();
$symptoms = $instance->applyExclusions($symptoms, $exclusions);
$symptoms = $instance->invertSymptoms($symptoms);
return $instance->extractCause($symptoms);
}
示例4: constructFailure
public static function constructFailure($status, $nwk_addr_of_interest)
{
$frame = new self();
$frame->setStatus($status);
$frame->setNwkAddrOfInterest($nwk_addr_of_interest);
return $frame;
}
示例5: get_template
public static function get_template($args = '')
{
global $l10n;
$defaults = array('locale' => null, 'title' => '');
$args = wp_parse_args($args, $defaults);
$locale = $args['locale'];
$title = $args['title'];
if ($locale) {
$mo_orig = $l10n['contact-form-7'];
wpcf7_load_textdomain($locale);
}
self::$current = $contact_form = new self();
$contact_form->title = $title ? $title : __('Untitled', 'contact-form-7');
$contact_form->locale = $locale ? $locale : get_locale();
$properties = $contact_form->get_properties();
foreach ($properties as $key => $value) {
$properties[$key] = WPCF7_ContactFormTemplate::get_default($key);
}
$contact_form->properties = $properties;
$contact_form = apply_filters('wpcf7_contact_form_default_pack', $contact_form, $args);
if (isset($mo_orig)) {
$l10n['contact-form-7'] = $mo_orig;
}
return $contact_form;
}
示例6: createCivil
public static function createCivil($input)
{
$answer = [];
$rules = ['number_civil' => 'required', 'date' => 'required', 'demandant' => 'required', 'defendant' => 'required', 'matery' => 'required', 'secretary' => 'required', 'file' => 'required'];
$validation = Validator::make($input, $rules);
if ($validation->fails()) {
$answer['message'] = $validation;
$answer['error'] = true;
} else {
$civil = new self();
$civil->number_civil = $input['number_civil'];
$civil->date = $input['date'];
$civil->demandant = $input['demandant'];
$civil->defendant = $input['defendant'];
$civil->matery = $input['matery'];
$civil->secretary = $input['secretary'];
$civil->file = $input['file'];
$civil->references = $input['references'];
$civil->description = $input['description'];
$civil->status = 1;
if ($civil->save()) {
$answer['message'] = 'Creado con exito!';
$answer['error'] = false;
} else {
$answer['message'] = 'CIVIL CREATE error, team noob!';
$answer['error'] = false;
}
}
return $answer;
}
示例7: style
/**
* Creates a stylesheet link with LESS support
*
* @param string $style file name
* @param array $attributes default attributes
* @param bool $index include the index page
* @param array $imports compare file date for these too, CSS and LESS in style @import
* @return string
*/
public static function style($file, array $attributes = null, $index = false, $imports = null)
{
$imports = (array) $imports;
// Compile only .less files
if (substr_compare($file, '.less', -5, 5, false) === 0) {
$css = substr_replace($file, 'css', -4);
$compiled = is_file($css) ? filemtime($css) : 0;
try {
// Check if imported files have changed
$compile = filemtime($file) > $compiled;
if (!$compile && !empty($imports)) {
foreach ($imports as $import) {
if (filemtime($import) > $compiled) {
$compile = true;
break;
}
}
}
// Compile LESS
if ($compile) {
$compiler = new self($file);
file_put_contents($css, $compiler->parse());
}
$file = $css;
} catch (Exception $e) {
Kohana::$log->add(Kohana::ERROR, __METHOD__ . ': Error compiling LESS file ' . $file . ', ' . $e->getMessage());
}
}
return HTML::style($file . '?' . filemtime($file), $attributes, $index);
}
示例8: setEntry
/**
* Set option
*
* @param $name
* @param $value
* @param null $context
* @param null $type
* @return bool
*/
public static function setEntry($name, $value, $context = null, $type = null)
{
$item = self::where('name', $name)->first();
if (!$item) {
$item = new self();
}
$item->name = $name;
if (!$type) {
if (is_string($value)) {
$type = 'string';
} else {
$type = 'serializable';
}
}
if ($type == 'serializable') {
$value = serialize($value);
} elseif ($type == 'json') {
$value = json_encode($value);
} elseif ($type == 'hashed') {
$value = Hash::make($value);
} elseif ($type == 'crypted') {
$value = Crypt::encrypt($value);
}
$item->value = $value;
$item->type = $type;
$item->context = $context;
return $item->save();
}
示例9: load
/**
* Load an image
*
* @param $filename
* @return Image
* @throws Exception
*/
public static function load($filename)
{
$instance = new self();
// Require GD library
if (!extension_loaded('gd')) {
throw new Exception('Required extension GD is not loaded.');
}
$instance->filename = $filename;
$info = getimagesize($instance->filename);
switch ($info['mime']) {
case 'image/gif':
$instance->image = imagecreatefromgif($instance->filename);
break;
case 'image/jpeg':
$instance->image = imagecreatefromjpeg($instance->filename);
break;
case 'image/png':
$instance->image = imagecreatefrompng($instance->filename);
imagesavealpha($instance->image, true);
imagealphablending($instance->image, true);
break;
default:
throw new Exception('Invalid image: ' . $instance->filename);
break;
}
$instance->original_info = array('width' => $info[0], 'height' => $info[1], 'orientation' => $instance->get_orientation(), 'exif' => function_exists('exif_read_data') ? $instance->exif = @exif_read_data($instance->filename) : null, 'format' => preg_replace('/^image\\//', '', $info['mime']), 'mime' => $info['mime']);
$instance->width = $info[0];
$instance->height = $info[1];
imagesavealpha($instance->image, true);
imagealphablending($instance->image, true);
return $instance;
}
示例10: create
/**
* Transforms a string or an array to a query object.
*
* If query is empty,
*
* @param mixed $query
*
* @throws \Elastica\Exception\NotImplementedException
*
* @return self
*/
public static function create($query)
{
switch (true) {
case $query instanceof self:
return $query;
case $query instanceof AbstractQuery:
return new self($query);
case $query instanceof AbstractFilter:
$newQuery = new self();
$newQuery->setPostFilter($query);
return $newQuery;
case empty($query):
return new self(new MatchAll());
case is_array($query):
return new self($query);
case is_string($query):
return new self(new QueryString($query));
case $query instanceof AbstractSuggest:
return new self(new Suggest($query));
case $query instanceof Suggest:
return new self($query);
}
// TODO: Implement queries without
throw new NotImplementedException();
}
示例11: addChat
public static function addChat($IDParent, $Type, $Tag, $Text, $IDUser = null)
{
$IDChat = parent::addChat($IDParent, $Text, $IDUser);
$TheChat = new self();
$Data = array('Tag' => $Tag, 'Type' => $Type);
return $TheChat->update($Data, "IDChat = '{$IDChat}'");
}
示例12: init
public static function init($run = true)
{
static $console;
if (!$console) {
// 实例化console
$console = new self('Think Console', '0.1');
// 读取指令集
if (is_file(CONF_PATH . 'command' . EXT)) {
$commands = (include CONF_PATH . 'command' . EXT);
if (is_array($commands)) {
foreach ($commands as $command) {
if (class_exists($command) && is_subclass_of($command, "\\think\\console\\command\\Command")) {
// 注册指令
$console->add(new $command());
}
}
}
}
}
if ($run) {
// 运行
$console->run();
} else {
return $console;
}
}
示例13: launch
public static function launch()
{/*{{{*/
$fix = new self();
$fix->mailbox = BeanFinder::get('configs')->aladdinMailbox;
$content = '';
try
{
//$fix->checkDiseaseHospitalInfo4Baidu();
//$fix->checkDiseaseInfo4Daidu();
//$fix->checkDoctorForBaidu();
//$fix->checkHospitalFacultyDoctorInfo();
//$fix->checkOfficeDoctor4Baidu();
//$fix->writeContent2File();
$fix->synFile();
$fix->sendEmail();
}
catch(Exception $ex)
{
$content .= $ex->getMessage();
}
if(false == empty($content))
{
EmailClient::getInstance()->sendSync($fix->mailbox, "阿拉丁监控脚本异常", $content, $type='text/html');
}
}/*}}}*/
示例14: initializeByString
/**
* Method for object initialization by the string
* @param string $string response string
* @return Error error object
*/
public static function initializeByString($string)
{
$object = json_decode($string);
$Response = new self();
$Response->setError($object->error);
return $Response;
}
示例15: setup_fake_attempt_layout
/**
* Set a fake page layout. Used when we test URL generation.
* @param int $id assumed attempt id.
* @param string $layout layout to set. Like quiz attempt.layout. E.g. '1,2,0,3,4,0,'.
* @param array $infos slot numbers which contain 'descriptions', or other non-questions.
* @return quiz_attempt attempt object for use in unit tests.
*/
public static function setup_fake_attempt_layout($id, $layout, $infos = array())
{
$attempt = new stdClass();
$attempt->id = $id;
$attempt->layout = $layout;
$course = new stdClass();
$quiz = new stdClass();
$cm = new stdClass();
$cm->id = 0;
$attemptobj = new self($attempt, $quiz, $cm, $course, false);
$attemptobj->slots = array();
foreach (explode(',', $layout) as $slot) {
if ($slot == 0) {
continue;
}
$attemptobj->slots[$slot] = new stdClass();
$attemptobj->slots[$slot]->slot = $slot;
$attemptobj->slots[$slot]->requireprevious = 0;
$attemptobj->slots[$slot]->questionid = 0;
}
$attemptobj->sections = array();
$attemptobj->sections[0] = new stdClass();
$attemptobj->sections[0]->heading = '';
$attemptobj->sections[0]->firstslot = 1;
$attemptobj->sections[0]->shufflequestions = 0;
$attemptobj->infos = $infos;
$attemptobj->link_sections_and_slots();
$attemptobj->determine_layout();
$attemptobj->number_questions();
return $attemptobj;
}