本文整理汇总了PHP中Factory::createOrGetDBHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::createOrGetDBHandler方法的具体用法?PHP Factory::createOrGetDBHandler怎么用?PHP Factory::createOrGetDBHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::createOrGetDBHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildSAIAction
static function buildSAIAction($eaiItem)
{
$result = array();
for ($i = 1; $i <= 3; $i++) {
$eaiAction = $eaiItem->{'action' . $i . '_type'};
if ($eaiAction == 0) {
break;
}
$param1 = $eaiItem->{'action' . $i . '_param1'};
$param2 = $eaiItem->{'action' . $i . '_param2'};
$param3 = $eaiItem->{'action' . $i . '_param3'};
switch ($eaiAction) {
case ACTION_T_TEXT:
$creatureAiTextEntry = Factory::createOrGetDBHandler()->query("SELECT * FROM `creature_ai_texts` WHERE `entry` IN (" . $param1 . "," . $param2 . "," . $param3 . ")")->fetchAll(PDO::FETCH_OBJ);
$result[$i] = array('extraData' => $creatureAiTextEntry, 'eaiActionParams' => array($param1, $param2, $param3), 'SAIAction' => SMART_ACTION_TALK, 'params' => array($param1, 0, 0, 0, 0, 0), 'target' => SMART_TARGET_SELF, 'commentType' => "_npcName_ - _eventName_ - Say Line _lineEntry_");
for ($x = 0; $x < sizeof($creatureAiTextEntry); $x++) {
$content_default = $creatureAiTextEntry[$x]->content_default;
if (strpos($content_default, '$C') !== false || strpos($content_default, '$c') !== false || strpos($content_default, '$R') !== false || strpos($content_default, '$r') !== false || strpos($content_default, '$N') !== false || strpos($content_default, '$n') !== false || strpos($content_default, '$T') !== false || strpos($content_default, '$t') !== false || strpos($content_default, '$G') !== false || strpos($content_default, '$g') !== false || strpos($content_default, '%T') !== false || strpos($content_default, '%t') !== false) {
$result[$i]['target'] = SMART_TARGET_ACTION_INVOKER;
break;
}
}
break;
case ACTION_T_SET_FACTION:
$result[$i] = array('SAIAction' => SMART_ACTION_SET_FACTION, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Set Faction " . $param1);
break;
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
$result[$i] = array('SAIAction' => SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL, 'params' => array($param1, $param2, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Set Displayid " . $param1);
break;
case ACTION_T_SOUND:
//! Second parameter in SAI means we 'onlySelf' (0 = only self, 1 = everybody around). In EAI this is 0 by default.
$result[$i] = array('SAIAction' => SMART_ACTION_SOUND, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Play Sound " . $param1);
break;
case ACTION_T_EMOTE:
$result[$i] = array('SAIAction' => SMART_ACTION_PLAY_EMOTE, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Emote ");
switch ($param1) {
case EMOTE_ONESHOT_WAVE_NO_SHEATHE:
case EMOTE_ONESHOT_WAVE:
$result[$i]['commentType'] .= "Wave";
break;
case EMOTE_ONESHOT_CHEER_NO_SHEATHE:
case EMOTE_ONESHOT_CHEER:
$result[$i]['commentType'] .= "Cheer";
break;
case EMOTE_ONESHOT_LAUGH_NO_SHEATHE:
case EMOTE_ONESHOT_LAUGH:
$result[$i]['commentType'] .= "Laugh";
break;
case EMOTE_ONESHOT_EAT_NO_SHEATHE:
case EMOTE_ONESHOT_EAT:
$result[$i]['commentType'] .= "Eat";
break;
case EMOTE_STATE_STUN_NO_SHEATHE:
case EMOTE_STATE_STUN:
$result[$i]['commentType'] .= "Stunned";
break;
case EMOTE_ONESHOT_SALUTE_NO_SHEATH:
case EMOTE_ONESHOT_SALUTE:
$result[$i]['commentType'] .= "Salute";
break;
case EMOTE_STATE_USE_STANDING_NO_SHEATHE:
case EMOTE_STATE_USE_STANDING:
$result[$i]['commentType'] .= "State Standing";
break;
case EMOTE_ONESHOT_TALK_NO_SHEATHE:
case EMOTE_ONESHOT_TALK:
$result[$i]['commentType'] .= "Talk";
break;
case EMOTE_ONESHOT_POINT_NO_SHEATHE:
case EMOTE_ONESHOT_POINT:
$result[$i]['commentType'] .= "Point";
break;
case EMOTE_STATE_EAT_NO_SHEATHE:
case EMOTE_STATE_EAT:
$result[$i]['commentType'] .= "State Eating";
break;
case EMOTE_ONESHOT_BOW:
$result[$i]['commentType'] .= "Bow";
break;
case EMOTE_ONESHOT_EXCLAMATION:
$result[$i]['commentType'] .= "Exclamation";
break;
case EMOTE_ONESHOT_QUESTION:
$result[$i]['commentType'] .= "Question";
break;
case EMOTE_STATE_DANCE:
$result[$i]['commentType'] .= "State Dance";
break;
case EMOTE_STATE_SLEEP:
$result[$i]['commentType'] .= "State Sleep";
break;
case EMOTE_STATE_SIT:
$result[$i]['commentType'] .= "State Sit";
break;
case EMOTE_ONESHOT_RUDE:
$result[$i]['commentType'] .= "Rude";
break;
case EMOTE_ONESHOT_ROAR:
$result[$i]['commentType'] .= "Roar";
break;
//.........这里部分代码省略.........
示例2: buildSAIAction
static function buildSAIAction($eaiItem)
{
$result = array();
for ($i = 1; $i <= 3; $i++) {
$eaiAction = $eaiItem->{'action' . $i . '_type'};
if ($eaiAction == 0) {
break;
}
$param1 = $eaiItem->{'action' . $i . '_param1'};
$param2 = $eaiItem->{'action' . $i . '_param2'};
$param3 = $eaiItem->{'action' . $i . '_param3'};
switch ($eaiAction) {
case ACTION_T_TEXT:
$result[$i] = array('extraData' => Factory::createOrGetDBHandler()->query("SELECT * FROM `creature_ai_texts` WHERE `entry` IN (" . $param1 . "," . $param2 . "," . $param3 . ")")->fetchAll(PDO::FETCH_OBJ), 'SAIAction' => SMART_ACTION_TALK, 'params' => array($param1, $param2, $param3, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Say Line _lineEntry_");
break;
case ACTION_T_SET_FACTION:
$result[$i] = array('SAIAction' => SMART_ACTION_SET_FACTION, 'params' => array($param1, $param2, $param3, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Set Faction " . $param1);
break;
case ACTION_T_MORPH_TO_ENTRY_OR_MODEL:
$result[$i] = array('SAIAction' => SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL, 'params' => array($param1, $param2, $param3, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Morph Into " . $param1);
break;
case ACTION_T_SOUND:
$result[$i] = array('SAIAction' => SMART_ACTION_SOUND, 'params' => array($param1, max(0, min($param2, 1)), 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Play Sound " . $param1);
break;
case ACTION_T_EMOTE:
$result[$i] = array('SAIAction' => SMART_ACTION_PLAY_EMOTE, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Play Emote " . $param1);
break;
case ACTION_T_RANDOM_EMOTE:
$result[$i] = array('SAIAction' => SMART_ACTION_RANDOM_EMOTE, 'params' => array($param1, $param2, $param3, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Random Emote");
break;
case ACTION_T_CAST:
$result[$i] = array('SAIAction' => SMART_ACTION_CAST, 'params' => array($param1, $param3, 0, 0, 0, 0), 'target' => $param2 + 1, 'commentType' => "_npcName_ - _eventName_ - Cast _castSpellId_");
break;
case ACTION_T_THREAT_SINGLE_PCT:
$target = $param2 + 1;
case ACTION_T_THREAT_ALL_PCT:
//! Wiki is wrong here, we can have two arguments. First is added threat, second is removed threat.
//! Threat addition has priority over threat reduction!
$result[$i] = array('SAIAction' => $eaiAction == ACTION_T_THREAT_SINGLE_PCT ? SMART_ACTION_THREAT_SINGLE_PCT : SMART_ACTION_THREAT_ALL_PCT, 'params' => array(max(0, $param1), max(0, -$param1), 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - ");
if (isset($target)) {
$result[$i]['target'] = $target;
}
if ($param1 < 0) {
$result[$i]['commentType'] .= "Remove " . -$param1 . '% Threat';
} else {
// if ($param1 > 0)
$result[$i]['commentType'] .= "Add " . -$param1 . '% Threat';
}
break;
case ACTION_T_QUEST_EVENT_ALL:
case ACTION_T_QUEST_EVENT:
$result[$i] = array('SAIAction' => SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Quest Credit");
if ($eaiAction == ACTION_T_QUEST_EVENT) {
$result[$i]['target'] = $param2 + 1;
}
break;
case ACTION_T_CAST_EVENT_ALL:
case ACTION_T_CAST_EVENT:
$result[$i] = array('SAIAction' => SMART_ACTION_CALL_CASTEDCREATUREORGO, 'params' => array($param1, $param2, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Quest Credit");
if ($eaiAction == ACTION_T_CAST_EVENT) {
$result[$i]['target'] = $param3 + 1;
}
break;
case ACTION_T_SET_UNIT_FIELD:
//! Not a 100% sure on this, requires deeper research. (Horn's comments based)
//! Not sure if it's param1 or param2!
$result[$i] = array('SAIAction' => SMART_ACTION_SET_UNIT_FIELD_BYTES_1, 'params' => array($param2, 0, 0, 0, 0, 0), 'target' => $param3 + 1, 'commentType' => "_npcName_ - _eventName_ - Set Bytes1 " . $param2);
break;
case ACTION_T_SET_UNIT_FLAG:
$result[$i] = array('SAIAction' => SMART_ACTION_SET_UNIT_FLAG, 'params' => array($param1, 0, 0, 0, 0, 0), 'target' => $param2 + 1, 'commentType' => "_npcName_ - _eventName_ - Set unit_flag " . $param1);
break;
case ACTION_T_REMOVE_UNIT_FLAG:
$result[$i] = array('SAIAction' => SMART_ACTION_REMOVE_UNIT_FLAG, 'params' => array($param1, 0, 0, 0, 0, 0), 'target' => $param2 + 1, 'commentType' => "_npcName_ - _eventName_ - Remove unit_flag " . $param1);
break;
case ACTION_T_AUTO_ATTACK:
$result[$i] = array('SAIAction' => SMART_ACTION_AUTO_ATTACK, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Start Auto Attack");
break;
case ACTION_T_COMBAT_MOVEMENT:
$result[$i] = array('SAIAction' => SMART_ACTION_ALLOW_COMBAT_MOVEMENT, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Allow Combat Movement");
break;
case ACTION_T_SET_PHASE:
$result[$i] = array('SAIAction' => SMART_ACTION_SET_EVENT_PHASE, 'params' => array($param1, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Set Phase " . $param1);
break;
case ACTION_T_INC_PHASE:
$result[$i] = array('SAIAction' => SMART_ACTION_INC_EVENT_PHASE, 'params' => array(0, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - " . ($param1 < 0 ? "De" : "In") . "crement Phase");
if ($param1 < 0) {
$result[$i]['params'][1] = -$param1;
} else {
// if ($param1 > 0)
$result[$i]['params'][0] = $param1;
}
break;
case ACTION_T_EVADE:
$result[$i] = array('SAIAction' => SMART_ACTION_EVADE, 'params' => array(0, 0, 0, 0, 0, 0), 'commentType' => "_npcName_ - _eventName_ - Evade");
break;
case ACTION_T_FLEE_FOR_ASSIST:
//! EAI has no parameter. I set the first one as 0 as default for the NPC not to emote when fleeing.
//! EAI needs another action for this. WE DONT. This action will be used to pick if we need to emote
//! on fleeing.
$result[$i] = array('SAIAction' => SMART_ACTION_FLEE_FOR_ASSIST, 'params' => array(0, 0, 0, 0, 0, 0), 'target' => SMART_TARGET_NONE, 'commentType' => "_npcName_ - _eventName_ - Flee For Assist");
//.........这里部分代码省略.........
示例3: ob_start
$EAIDataSet = Factory::createOrGetDBHandler()->query("SELECT a.* FROM creature_ai_scripts a")->fetchAll(PDO::FETCH_OBJ);
ob_start();
echo '>> Gotten ' . count($EAIDataSet) . ' entries in ' . round(microtime(true) - $oldDate, 4) . ' ms' . PHP_EOL;
echo PHP_EOL . 'Grouping entries by NPC ...' . PHP_EOL;
ob_end_flush();
$npcName = "";
// Save the last iterated NPC name
$npcId = 0;
// And its entry in the table.
$npcStore = array();
$oldDate = microtime(true);
$forbiddenNpcs = array();
foreach ($EAIDataSet as $eaiItem) {
if ($npcId != $eaiItem->creature_id) {
# New NPC. Create a corresponding NPC class instance.
$npcInfo = Factory::createOrGetDBHandler()->query('SELECT name, flags_extra FROM creature_template WHERE entry = ' . $eaiItem->creature_id)->fetch(PDO::FETCH_OBJ);
if ($npcInfo->flags_extra & 1) {
if (!in_array($npcInfo->name, $forbiddenNpcs)) {
$forbiddenNpcs[] = $npcInfo->name;
}
continue;
}
$npcId = $eaiItem->creature_id;
$npcStore[$npcId] = new NPC($npcId, $npcInfo->name);
}
$eaiItem->npcName = $npcName;
$eaiItem->npcId = $npcId;
$npcStore[$npcId]->addEAI($eaiItem);
}
unset($eaiItem, $npcName, $npcId, $EAIDataSet);
// Save some memory
示例4: ob_end_flush
echo " \\ \\ \\/\\`'__\\/\\ \\ /' _ `\\/\\ \\ \\ \\/ /\\ \\/\\ \\" . PHP_EOL;
echo " \\ \\ \\ \\ \\/ \\ \\ \\/\\ \\/\\ \\ \\ \\ \\ \\_\\ \\ \\_\\ \\" . PHP_EOL;
echo " \\ \\_\\ \\_\\ \\ \\_\\ \\_\\ \\_\\ \\_\\ \\__\\\\/`____ \\" . PHP_EOL;
echo " \\/_/\\/_/ \\/_/\\/_/\\/_/\\/_/\\/__/ `/___/> \\" . PHP_EOL;
echo " C O R E /\\___/" . PHP_EOL;
echo "http://TrinityCore.org \\/__/\n" . PHP_EOL;
ob_end_flush();
if ($iniFile = parse_ini_file('config.ini')) {
Factory::setDbData($iniFile['hostname'], $iniFile['userName'], $iniFile['password'], $iniFile['worldDatabase']);
echo '>> Config file found and parsed sucessfully.' . PHP_EOL;
}
ob_start();
echo PHP_EOL . 'Selecting all SmartAIs from the database ...' . PHP_EOL;
ob_end_flush();
$oldDate = microtime(true);
$SAIDataSet = Factory::createOrGetDBHandler()->query("SELECT a.* FROM smart_scripts a")->fetchAll(PDO::FETCH_OBJ);
ob_start();
echo '>> Gotten ' . count($SAIDataSet) . ' entries in ' . round(microtime(true) - $oldDate, 4) . ' ms' . PHP_EOL;
echo PHP_EOL . 'Grouping entries by NPC ...' . PHP_EOL;
ob_end_flush();
$entryorguid = 0;
// Last iterated entry
$npcStore = array();
$oldDate = microtime(true);
foreach ($SAIDataSet as &$saiItem) {
if ($entryorguid != $saiItem->entryorguid) {
# New NPC. Create a corresponding NPC class instance.
$entryorguid = $saiItem->entryorguid;
$npcStore[$entryorguid] = array();
}
$npcStore[$entryorguid][$saiItem->id] = array('link' => intval($saiItem->link), 'eventType' => intval($saiItem->event_type));
示例5: microtime
$oldDate = microtime(true);
$EAIDataSet = Factory::createOrGetDBHandler()->query("SELECT * FROM creature_ai_scripts ORDER BY id")->fetchAll(PDO::FETCH_OBJ);
ob_start();
echo '>> Gotten ' . count($EAIDataSet) . ' entries in ' . round(microtime(true) - $oldDate, 4) . ' ms' . PHP_EOL;
echo PHP_EOL . 'Grouping entries by NPC ...' . PHP_EOL;
ob_end_flush();
$npcName = "";
// Save the last iterated NPC name
$npcId = 0;
// And its entry in the table.
$npcStore = array();
$oldDate = microtime(true);
foreach ($EAIDataSet as $eaiItem) {
if ($npcId != $eaiItem->creature_id) {
# New NPC. Create a corresponding NPC class instance.
$npcName = Factory::createOrGetDBHandler()->query('SELECT name FROM creature_template WHERE entry = ' . $eaiItem->creature_id)->fetch(PDO::FETCH_OBJ)->name;
$npcId = $eaiItem->creature_id;
$npcStore[$npcId] = new NPC($npcId, $npcName);
}
$eaiItem->npcName = $npcName;
$eaiItem->npcId = $npcId;
$npcStore[$npcId]->addEAI($eaiItem);
}
unset($eaiItem, $npcName, $npcId, $EAIDataSet);
// Save some memory
$storeSize = count($npcStore);
# Delete previous files
if (file_exists('creature_texts.sql')) {
unlink('creature_texts.sql');
}
if (file_exists('smart_scripts.sql')) {