本文整理匯總了PHP中Variable::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::find方法的具體用法?PHP Variable::find怎麽用?PHP Variable::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Variable
的用法示例。
在下文中一共展示了Variable::find方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getAllObjects
function getAllObjects()
{
$variableList = array();
$variable = new Variable();
$variable->orderBy('name');
$variable->find();
while ($variable->fetch()) {
$variableList[$variable->id] = clone $variable;
}
return $variableList;
}
示例2: getIndexStatus
function getIndexStatus()
{
// global $serverName;
$partialIndexUpToDate = false;
$fullIndexUpToDate = false;
$overDriveExtractUpToDate = false;
$solrRestartUpToDate = false;
$notes = array();
$currentTime = time();
// Full Index //
$lastFullIndexVariable = new Variable();
$lastFullIndexVariable->name = 'lastFullReindexFinish';
if ($lastFullIndexVariable->find(true)) {
//Check to see if the last full index finished more than FULL_INDEX_INTERVAL seconds ago
if ($lastFullIndexVariable->value >= $currentTime - self::FULL_INDEX_INTERVAL) {
$fullIndexUpToDate = true;
} else {
$notes[] = 'Full Index last finished ' . date('m-d-Y H:i:s', $lastFullIndexVariable->value) . ' - ' . round(($currentTime - $lastFullIndexVariable->value) / 3600, 2) . ' hours ago';
}
} else {
$notes[] = 'Full index has never been run';
}
// Partial Index //
$lastPartialIndexVariable = new Variable();
$lastPartialIndexVariable->name = 'lastPartialReindexFinish';
if ($lastPartialIndexVariable->find(true)) {
//Check to see if the last partial index finished more than PARTIAL_INDEX_INTERVAL seconds ago
if ($lastPartialIndexVariable->value >= $currentTime - self::PARTIAL_INDEX_INTERVAL) {
$partialIndexUpToDate = true;
} else {
$notes[] = 'Partial Index last finished ' . date('m-d-Y H:i:s', $lastPartialIndexVariable->value) . ' - ' . round(($currentTime - $lastPartialIndexVariable->value) / 60, 2) . ' minutes ago';
}
} else {
$notes[] = 'Partial index has never been run';
}
// OverDrive Extract //
$lastOverDriveExtractVariable = new Variable();
$lastOverDriveExtractVariable->name = 'last_overdrive_extract_time';
if ($lastOverDriveExtractVariable->find(true)) {
//Check to see if the last partial index finished more than OVERDRIVE_EXTRACT_INTERVAL seconds ago
$lastOverDriveExtractTime = $lastOverDriveExtractVariable->value / 1000;
if ($lastOverDriveExtractTime >= $currentTime - self::OVERDRIVE_EXTRACT_INTERVAL) {
$overDriveExtractUpToDate = true;
} else {
$notes[] = 'OverDrive Extract last finished ' . date('m-d-Y H:i:s', $lastOverDriveExtractTime) . ' - ' . round(($currentTime - $lastOverDriveExtractTime) / 3600, 2) . ' hours ago';
}
} else {
$notes[] = 'OverDrive Extract has never been run';
}
// Solr Restart //
global $configArray;
if ($configArray['Index']['engine'] == 'Solr') {
$xml = @file_get_contents($configArray['Index']['url'] . '/admin/cores');
if ($xml) {
$options = array('parseAttributes' => 'true', 'keyAttribute' => 'name');
$unxml = new XML_Unserializer($options);
$unxml->unserialize($xml);
$data = $unxml->getUnserializedData();
$uptime = $data['status']['grouped']['uptime']['_content'] / 1000;
// Grouped Index, puts uptime into seconds.
$uptime2 = $data['status']['grouped2']['uptime']['_content'] / 1000;
// Grouped 2 Index, puts uptime into seconds.
$solrStartTime = strtotime($data['status']['grouped']['startTime']['_content']);
$solrStartTime2 = strtotime($data['status']['grouped2']['startTime']['_content']);
if ($uptime < self::SOLR_RESTART_INTERVAL) {
// Grouped Index
if ($uptime2 < self::SOLR_RESTART_INTERVAL) {
// Grouped 2 Index
$solrRestartUpToDate = true;
} else {
$notes[] = 'Solr Index (Grouped2) last restarted ' . date('m-d-Y H:i:s', $solrStartTime) . ' - ' . round($uptime / 3600, 2) . ' hours ago';
}
} else {
$notes[] = 'Solr Index (Grouped) last restarted ' . date('m-d-Y H:i:s', $solrStartTime2) . ' - ' . round($uptime / 3600, 2) . ' hours ago';
}
}
// else {
// Notice if XML wasn't readable? eg Solr not responding
// }
}
if (!$fullIndexUpToDate || !$partialIndexUpToDate || !$overDriveExtractUpToDate || !$solrRestartUpToDate) {
$result = array('result' => false, 'message' => implode('; ', $notes));
} else {
$result = array('result' => true, 'message' => "Everything is current");
}
return $result;
}
示例3: loadUserData
function loadUserData()
{
global $user;
global $interface;
//Load profile information
$catalog = CatalogFactory::getCatalogConnectionInstance();
$profile = $catalog->getMyProfile($user);
if (!PEAR_Singleton::isError($profile)) {
$interface->assign('profile', $profile);
}
//Load a list of lists
$lists = array();
require_once ROOT_DIR . '/sys/LocalEnrichment/UserList.php';
$tmpList = new UserList();
$tmpList->user_id = $user->id;
$tmpList->deleted = 0;
$tmpList->orderBy("title ASC");
$tmpList->find();
if ($tmpList->N > 0) {
while ($tmpList->fetch()) {
$lists[$tmpList->id] = array('name' => $tmpList->title, 'url' => '/MyAccount/MyList/' . $tmpList->id, 'id' => $tmpList->id, 'numTitles' => $tmpList->num_titles());
}
}
$interface->assign('lists', $lists);
// Get My Tags
$tagList = $user->getTags();
$interface->assign('tagList', $tagList);
if ($user->hasRole('opacAdmin') || $user->hasRole('libraryAdmin') || $user->hasRole('cataloging')) {
$variable = new Variable();
$variable->name = 'lastFullReindexFinish';
if ($variable->find(true)) {
$interface->assign('lastFullReindexFinish', date('m-d-Y H:i:s', $variable->value));
} else {
$interface->assign('lastFullReindexFinish', 'Unknown');
}
$variable = new Variable();
$variable->name = 'lastPartialReindexFinish';
if ($variable->find(true)) {
$interface->assign('lastPartialReindexFinish', date('m-d-Y H:i:s', $variable->value));
} else {
$interface->assign('lastPartialReindexFinish', 'Unknown');
}
}
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$this->variable->find($id)->delete();
return Redirect::route('variables.index');
}