本文整理汇总了PHP中PEAR::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::isError方法的具体用法?PHP PEAR::isError怎么用?PHP PEAR::isError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::isError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: com_install
function com_install($mypath = '')
{
error_reporting(E_ALL ^ E_NOTICE);
global $database;
if (is_callable(array('JFactory', 'getDBO'))) {
$database = JFactory::getDBO();
}
if ($mypath == '') {
$mypath = dirname(__FILE__);
}
require_once $mypath . "/include/functions.php";
require_once $mypath . "/libraries/Archive/archive.php";
ext_RaiseMemoryLimit('50M');
$archive_name = $mypath . '/scripts.tar.gz';
$extract_dir = $mypath . '/';
$result = extArchive::extract($archive_name, $extract_dir);
if (!@PEAR::isError($result)) {
unlink($archive_name);
} else {
echo '<pre style="color:white; font-weight:bold; background-color:red;">Error!
' . $result->getMessage() . '
</pre>';
}
if (!is_callable(array($database, 'loadNextRow'))) {
$database->setQuery("SELECT id FROM #__components WHERE admin_menu_link = 'option=com_extplorer'");
$id = $database->loadResult();
//add new admin menu images
$database->setQuery("UPDATE #__components SET admin_menu_img = '../administrator/components/com_extplorer/images/x_icon.png', admin_menu_link = 'option=com_extplorer' WHERE id={$id}");
$database->query();
}
}
示例2: _logExpectedConstructive
function _logExpectedConstructive()
{
$aExistingTables = $this->oDBUpgrade->_listTables();
$prefix = $this->oDBUpgrade->prefix;
$msg = $this->_testName('A');
if (!in_array($prefix . 'astro', $aExistingTables)) {
$this->_log($msg . ' table ' . $prefix . 'astro does not exist in database therefore changes_tables_core_999200 will not be able to alter fields for table ' . $prefix . 'astro');
} else {
$this->_log($msg . ' add (as part of rename) field to table ' . $prefix . 'astro defined as: [id_changed_field]');
$aDef = $this->oDBUpgrade->aDefinitionNew['tables']['astro']['fields']['id_changed_field'];
$this->_log(print_r($aDef, true));
$msg = $this->_testName('B');
$this->_log($msg . ' add field to table ' . $prefix . 'astro defined as: [text_field]');
$aDef = $this->oDBUpgrade->aDefinitionNew['tables']['astro']['fields']['text_field'];
$this->_log(print_r($aDef, true));
$msg = $this->_testName('C');
$query = 'SELECT * FROM ' . $prefix . 'astro';
$result = $this->oDbh->queryAll($query);
if (PEAR::isError($result)) {
$this->_log($msg . ' failed to locate data to migrate from [id_field, desc_field] to [id_changed_field, text_field]');
} else {
$this->_log($msg . ' migrate data from [id_field, desc_field] to [id_changed_field, text_field] :');
$this->_log('row = id_field , desc_field');
foreach ($result as $k => $v) {
$this->_log('row ' . $k . ' = ' . $v['id_field'] . ' , ' . $v['desc_field']);
}
}
}
}
示例3: getPage
/**
* @brief lifepod 페이지 정보 가져오기
* @remarks 한해씩 끊어서 페이지를 가져옵니다. 아직 50개 이상의 calendar info가 있는 경우 앞에 것만 가져오는 문제가 있습니다.
**/
function getPage($address, $year, $pageNumber)
{
if ($year == null) {
$year = date("Y");
}
$start = sprintf("%s-01-01", $year);
$end = sprintf("%s-01-01", $year + 1);
$url = $this->getURL($address, $start, $end, $pageNumber);
$oReqeust = $this->getRequest($url);
$oResponse = $oReqeust->sendRequest();
if (PEAR::isError($oResponse)) {
return null;
}
$body = $oReqeust->getResponseBody();
$oXmlParser = new GeneralXmlParser();
$xmldoc = $oXmlParser->parse($body);
if (!$xmldoc->childNodes["feed"]->childNodes["entry"]) {
$data = array();
} else {
$data =& $xmldoc->childNodes["feed"]->childNodes["entry"]->childNodes["data"];
}
$page->title = $xmldoc->childNodes["feed"]->childNodes["title"]->body;
if (is_array($data)) {
$page->data = $data;
} else {
$page->data = array();
$page->data[] = $data;
}
$page->color = $xmldoc->childNodes["feed"]->childNodes["color"]->body;
$page->total = intval($xmldoc->childNodes["feed"]->childNodes["opensearch:totalresults"]->body);
$page->start = intval($xmldoc->childNodes["feed"]->childNodes["opensearch:startindex"]->body);
$page->perpage = intval($xmldoc->childNodes["feed"]->childNodes["opensearch:itemsperpage"]->body);
return $page;
}
示例4: parseFile
/**
* Read menu file. Parse xml and initializate menu.
*
* @param menu string Configuration file
* @param cacheFile string Name of file where parsed config will be stored for faster loading
* @return void
*/
public function parseFile(RM_Account_iUser $obUser)
{
PROFILER_IN('Menu');
$cacheFile = $this->_filepath . '.' . L(NULL) . '.cached';
if ($this->_cache_enabled and file_exists($cacheFile) and filemtime($cacheFile) > filemtime($this->_filepath)) {
$this->_rootArray = unserialize(file_get_contents($cacheFile));
} else {
#
# Initializing PEAR config engine...
#
$old = error_reporting();
error_reporting($old & ~E_STRICT);
require_once 'Config.php';
$conf = new Config();
$this->_root = $conf->parseConfig($this->_filepath, 'XML');
if (PEAR::isError($this->_root)) {
error_reporting($old);
throw new Exception(__METHOD__ . '(): Error while reading menu configuration: ' . $this->_root->getMessage());
}
$this->_rootArray = $this->_root->toArray();
if ($this->_cache_enabled) {
file_put_contents($cacheFile, serialize($this->_rootArray));
}
}
$arr = array_shift($this->_rootArray);
$arr = $arr['menu'];
$this->_menuData['index'] = array();
// index for branches
$this->_menuData['default'] = array();
// default selected block of menu
$this->_menuData['tree'] = $this->formMenuArray($obUser, $arr['node']);
$this->_menuData['branches'] = array();
// tmp array, dont cached
PROFILER_OUT('Menu');
}
示例5: checkDownloads
public function checkDownloads()
{
$pear = new Varien_Pear();
$pkg = new PEAR_PackageFile($pear->getConfig(), false);
$result = true;
foreach ($this->getPackages() as $package) {
$obj = $pkg->fromAnyFile($package, PEAR_VALIDATE_NORMAL);
if (PEAR::isError($obj)) {
$uinfo = $obj->getUserInfo();
if (is_array($uinfo)) {
foreach ($uinfo as $message) {
if (is_array($message)) {
$message = $message['message'];
}
Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
} else {
print_r($obj->getUserInfo());
#Mage::getSingleton('Mage_Install_Model_Session')->addError($message);
}
$result = false;
}
}
return $result;
}
示例6: __construct
function __construct($cmid = 0)
{
global $db;
$this->_cmid = $cmid;
if ($this->_cmid != 0) {
$this->_dbo = DB_DataObject::Factory("phph_comments");
if (PEAR::isError($this->_dbo)) {
throw new Exception2("Bd wewn�rzny", $this->_dbo->getMessage());
}
$r = $this->_dbo->get($cmid);
if (PEAR::isError($r)) {
throw new Exception2("Bd wewn�rzny", $r->getMessage());
}
if ($r == 0) {
throw new Exception2("Bd", "Komentarz nie istnieje", COMMENT_NOT_FOUND);
}
$this->_user = DB_DataObject::Factory("phph_users");
if (PEAR::isError($this->_user)) {
throw new Exception2("Bd wewn�rzny", $this->_user->getMessage());
}
$r = $this->_user->get($this->_dbo->user_id);
if (PEAR::isError($r)) {
throw new Exception2("Bd wewn�rzny", $r->getMessage());
}
if ($r == 0) {
throw new Exception2("Bd sp�noci danych", "Uytkownik do kt�ego nalezy komentarz nie istnieje.<br />Skontakuj si�z administratorem, podajc numer komentarza ({$cmid}).", COMMENT_USER_NOT_FOUND);
}
}
}
示例7: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->checkPluginExists($arguments['plugin']);
$this->pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration($arguments['plugin'])->getRootDir();
$this->interactive = !$options['non-interactive'];
$cleanup = array();
if (!file_exists($this->pluginDir . '/package.xml')) {
$cleanup['temp_files'] = array();
foreach (sfFinder::type('dir')->in($this->pluginDir) as $dir) {
if (!sfFinder::type('any')->maxdepth(0)->in($dir)) {
$this->getFilesystem()->touch($file = $dir . '/.sf');
$cleanup['temp_files'][] = $file;
}
}
$cleanup['package_file'] = true;
$this->generatePackageFile($arguments, $options);
}
$cwd = getcwd();
chdir($this->pluginDir);
$this->getPluginManager()->configure();
require_once 'PEAR/Packager.php';
$packager = new PEAR_Packager();
$package = $packager->package($this->pluginDir . '/package.xml', !$options['nocompress']);
chdir($cwd);
if (PEAR::isError($package)) {
if (isset($cleanup['package_file'])) {
$cleanup['package_file'] = '.error';
}
$this->cleanup($cleanup);
throw new sfCommandException($package->getMessage());
}
$this->cleanup($cleanup);
}
示例8: get_all_quotes
/** pulling in quotes from all avail types and putting into a nice array
*/
function get_all_quotes(cmCart $cart, $adder = 0)
{
$res = array();
$this->_cart =& $cart;
/* does this look like a PO Box? if so bail, with an error */
if ($this->_dest['country'] == 'US' && preg_match('/^(P\\.?O\\.?\\s*)?BOX\\s+[0-9]+/i', $this->_dest['addr'])) {
return $this->raiseError('FedEx cannot deliver to P.O. Boxes');
}
$allquotes = $this->quote();
if (!is_array($allquotes)) {
$msg = $this->_name . ": Shipping calculation error >> ";
$msg .= PEAR::isError($allquotes) ? $allquotes->getMessage() : $allquotes;
return $this->raiseError($msg);
}
asort($allquotes);
// sort the quotes by cost
foreach ($allquotes as $type => $q) {
if (in_array($type, $this->allowed_ship_types)) {
$q += $adder;
$opt = sprintf("%s %s (%.02f)", $this->get_name(), $this->ship_types[$type], $q);
$res[$opt] = $opt;
}
}
if ($this->debug) {
$log = "\n==> QUOTES: (adder={$adder}) " . join(";", array_keys($res)) . "\n";
error_log($log, 3, $this->debug_log);
}
return $res;
}
示例9: ModulePage
/**
* The constructor of the generic module
* class, ModulePage (Page.Module.class.php)
* <br>
* Takes global variables like TrEng and GlobalDatabase
* and sets the variables that will be used throughout
* the class
* @access public
* @param string $group
* @param string $modulecode
* @return ModulePage
*/
function ModulePage($modulecode)
{
global $GlobalDatabase;
global $treng;
_filter_var($group);
if (isset($GlobalDatabase)) {
$this->Database = $GlobalDatabase;
} else {
include 'configs/globals.php';
$dsn = array('phptype' => $db_type, 'username' => $db_username, 'password' => $db_password, 'hostspec' => $db_host, 'database' => $db_name);
$options = array('debug' => 2, 'portability' => DB_PORTABILITY_ALL);
$this->Database =& DB::connect($dsn, $options);
if (PEAR::isError($this->Database)) {
die($this->Database->getMessage());
}
$q =& $this->Database->query("SET NAMES utf8;");
if (PEAR::isError($q)) {
die($q->getMessage());
}
}
if (isset($treng)) {
$this->TrEng = $treng;
} else {
$this->TrEng = new TranslationEngine();
}
$this->ModuleCode = $modulecode;
}
示例10: _initializeDepDB
function _initializeDepDB()
{
if (!isset($this->_dependencyDB)) {
static $initializing = false;
if (!$initializing) {
$initializing = true;
if (!$this->_config) {
// never used?
if (OS_WINDOWS) {
$file = 'pear.ini';
} else {
$file = '.pearrc';
}
$this->_config =& new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR . $file, '-');
// NO SYSTEM INI FILE
$this->_config->setRegistry($this);
$this->_config->set('php_dir', $this->install_dir);
}
$this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
if (PEAR::isError($this->_dependencyDB)) {
// attempt to recover by removing the dep db
if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb')) {
@unlink($this->_config->get('php_dir', null, 'pear.php.net') . DIRECTORY_SEPARATOR . '.depdb');
}
$this->_dependencyDB =& PEAR_DependencyDB::singleton($this->_config);
if (PEAR::isError($this->_dependencyDB)) {
echo $this->_dependencyDB->getMessage();
echo 'Unrecoverable error';
exit(1);
}
}
$initializing = false;
}
}
}
示例11: perform
function perform(&$page, $actionName)
{
// save the form values and validation status to the session
$page->isFormBuilt() or $page->buildForm();
$pageName = $page->getAttribute('id');
$data =& $page->controller->container();
$data['values'][$pageName] = $page->exportValues();
if (PEAR::isError($valid = $page->validate())) {
return $valid;
}
$data['valid'][$pageName] = $valid;
// Modal form and page is invalid: don't go further
if ($page->controller->isModal() && !$data['valid'][$pageName]) {
return $page->handle('display');
}
// More pages?
if (null !== ($nextName = $page->controller->getNextName($pageName))) {
$next =& $page->controller->getPage($nextName);
return $next->handle('jump');
// Consider this a 'finish' button, if there is no explicit one
} elseif ($page->controller->isModal()) {
if ($page->controller->isValid()) {
return $page->handle('process');
} else {
// this should redirect to the first invalid page
return $page->handle('jump');
}
} else {
return $page->handle('display');
}
}
示例12: testAddUser
function testAddUser()
{
if ($this->skip_tests) {
$this->fail($this->skip_tests_message . '');
return false;
}
$cb = count($this->container->listUsers());
$res = $this->container->addUser($this->user, $this->pass, $this->opt);
if (AUTH_METHOD_NOT_SUPPORTED === $res) {
$this->fail("This operation is not supported by " . get_class($this->container));
return false;
}
if (PEAR::isError($res)) {
$error = $res->getMessage() . ' [' . $res->getUserInfo() . ']';
} else {
$error = '';
}
$this->assertTrue(!PEAR::isError($res), 'error:' . $error);
$ca = count($this->container->listUsers());
$users = $this->container->listUsers();
$last_username = $users[$ca - 1]['username'];
$this->assertTrue($cb === $ca - 1, sprintf('Count of users before (%s) and after (%s) does not differ by one', $cb, $ca));
$this->assertTrue($this->container->fetchData($this->user, $this->pass), sprintf('Could not verify with the newly created user %s', $this->user));
// Remove the user we just added, assumes removeUser works
$this->container->removeUser($this->user);
}
示例13: _logActualConstructive
function _logActualConstructive()
{
$aExistingTables = $this->oDBUpgrade->_listTables();
$prefix = $this->oDBUpgrade->prefix;
if (in_array($prefix . 'astro', $aExistingTables)) {
$msg = $this->_testName('A');
$aDef = $this->oDBUpgrade->_getDefinitionFromDatabase('astro');
if (isset($aDef['tables']['astro']['fields']['id_changed_field'])) {
$this->_log($msg . ' added (as part of rename) field to table ' . $prefix . 'astro defined as: [id_changed_field]');
$this->_log(print_r($aDef['tables']['astro']['fields']['id_changed_field'], true));
} else {
$this->_log($msg . 'failed to add (as part of rename) field to table ' . $prefix . 'astro defined as: [id_changed_field]');
}
$msg = $this->_testName('B');
if (isset($aDef['tables']['astro']['fields']['text_field'])) {
$this->_log($msg . ' add field to table ' . $prefix . 'astro defined as: [text_field]');
$this->_log(print_r($aDef['tables']['astro']['fields']['text_field'], true));
} else {
$this->_log($msg . ' failed to add field to table ' . $prefix . 'astro defined as: [text_field]');
}
$msg = $this->_testName('C');
$query = 'SELECT * FROM ' . $prefix . 'astro';
$result = $this->oDbh->queryAll($query);
if (PEAR::isError($result)) {
$this->_log($msg . 'failed to migrate data from [id_field, desc_field] to [id_changed_field, text_field]');
} else {
$this->_log($msg . ' migrate data from [id_field, desc_field] to [id_changed_field, text_field] :');
$this->_log('row = id_changed_field , desc_field, text_field');
foreach ($result as $k => $v) {
$this->_log('row ' . $k . ' = ' . $v['id_changed_field'] . ' , ' . $v['desc_field'] . ' , ' . $v['text_field']);
}
}
}
}
示例14: check_db_result
function check_db_result(&$res)
{
if (PEAR::isError($res)) {
trigger_error("Database Error: " . print_r($res->userinfo, 1), E_USER_ERROR);
exit;
}
}
示例15: launch
/**
* Process incoming parameters and display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $interface;
global $configArray;
if (isset($_POST['submit'])) {
$result = $this->sendEmail($_POST['to'], $_POST['from'], $_POST['message']);
if (!PEAR::isError($result)) {
include_once 'Home.php';
Home::launch();
exit;
} else {
$interface->assign('errorMsg', $result->getMessage());
}
}
// Display Page
$interface->assign('formTargetPath', '/MetaLib/' . urlencode($_GET['id']) . '/Email');
$interface->assign('recordId', urlencode($_GET['id']));
if (isset($_GET['lightbox'])) {
$interface->assign('title', $_GET['message']);
return $interface->fetch('MetaLib/email.tpl');
} else {
$interface->setPageTitle('Email Record');
$interface->assign('subTemplate', 'email.tpl');
$interface->setTemplate('view-alt.tpl');
$interface->display('layout.tpl', 'RecordEmail' . $_GET['id']);
}
}