本文整理汇总了PHP中I2CE::pearError方法的典型用法代码示例。如果您正苦于以下问题:PHP I2CE::pearError方法的具体用法?PHP I2CE::pearError怎么用?PHP I2CE::pearError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I2CE
的用法示例。
在下文中一共展示了I2CE::pearError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_initialize
/**
* Make sure the float column is in the database in the entry/last entry tables.
*/
public function action_initialize()
{
//check to see that the large blobs are there.
foreach (array('entry', 'last_entry') as $table) {
$qry_show = "SHOW COLUMNS FROM {$table} LIKE '%_value'";
$qry_alter = "ALTER TABLE {$table} ADD COLUMN `float_value` float";
$results = $this->db->query($qry_show);
if (I2CE::pearError($results, "Error getting columns from {$table} table: on {$qry_show}")) {
return false;
}
$found = false;
while ($row = $results->fetchRow()) {
if ($row->field == 'float_value') {
$found = true;
}
}
if (!$found) {
//add the blob column to last_entry
if (I2CE::pearError($this->db->exec($qry_alter), "Error adding float column to {$table}:")) {
return false;
}
}
}
return true;
}
示例2: addLastModifiedColumn
/**
* Adds the last_modifed column to the uuid_map table if it is not there
* @returns true on success
*/
protected function addLastModifiedColumn()
{
$db = MDB2::singleton();
$rows = $db->queryAll("SHOW FULL COLUMNS FROM `uuid_map` WHERE Field='last_modifed'");
if (count($rows) > 0) {
I2CE::raiseError("uuid_map table already has last_modifed");
} else {
$qry_alter = "ALTER TABLE `uuid_map` ADD COLUMN `last_modified` timestamp NULL DEFAULT CURRENT_TIMESTAMP;";
if (I2CE::pearError($db->exec($qry_alter), "Error adding parent_id, parent_form column to {$table} table:")) {
return false;
}
}
return true;
}
示例3: createTable
public function createTable()
{
$qry = 'CREATE TABLE IF NOT EXISTS form_relationship_importer (
hash char(32) NOT NULL,
relationship text NOT NULL,
id text NOT NULL,
KEY hash_rey ( hash, relationship (130) )
) ENGINE=InnoDB DEFAULT CHARSET=utf8
';
$db = MDB2::singleton();
$result = $db->query($qry);
if (I2CE::pearError($result, "Cannot execute query:\n{$qry}")) {
I2CE::raiseError("Could not create form_relationship_importer table");
return false;
}
return true;
}
示例4: upgrade
/**
* Run the upgrade for this module.
* @param string $old_vers
* @param string $new_vers
* @return boolean
*/
public function upgrade($old_vers, $new_vers)
{
if (I2CE_Validate::checkVersion($old_vers, '<', '4.0.3.2')) {
I2CE::raiseError("Upgrading sample data for license end_date");
$db = MDB2::singleton();
$updated = $db->exec("UPDATE last_entry SET date = NOW(), date_value = '2015-01-01 00:00:00' WHERE form_field = 75 AND date_value = '2010-01-01 00:00:00'");
if (!I2CE::pearError($updated, "Unable to update license end_date for Qualify Sample Data.")) {
I2CE::raiseError("Update {$updated} entries.");
$last_mod = $db->exec("UPDATE record SET last_modified = NOW() WHERE form = 16");
if (!I2CE::pearError($last_mod, "Unable to update license end_date for Qualify Sample Data record last modified.")) {
I2CE::raiseError("Updated {$last_mod} records.");
} else {
return false;
}
} else {
return false;
}
I2CE::getConfig()->modules->CachedForms->dirty->license = time();
}
return parent::upgrade($old_vers, $new_vers);
}
示例5: setRole
/**
* Sets the role in the ldap hierarchy for the indicated user
* @param string $username
* @param string $role
* @returns boolean. true on success
*/
protected function setRole($username, $role)
{
if (!$this->options['can_change_user_role']) {
return false;
}
$qry = "INSERT INTO " . $this->options['user_table'] . " (role,username) VALUES (?, ?) ON DUPLICATE KEY UPDATE role = ?";
$params = array($role, $username, $role);
if (I2CE::pearError($this->db->execParam($qry, $params, array('text', 'text', 'text')), "Cannot update user role")) {
return false;
}
return true;
}
示例6: _createUser
/**
* Create user worker method
* @param string $username
* @param string $password
* @param string $role
* @param array $details. Defatuls to empty array,
* @returns boolean. true on success
*/
public function _createUser($username, $password, $role = false, $details = array())
{
$qry = "INSERT INTO " . $this->passTable . " ( username, password) VALUES (?,?)";
$params = array($username, $this->encryptPassword($password));
if (I2CE::pearError($this->db->execParam($qry, $params, array('text', 'text')), "Cannot create user {$username}")) {
return false;
}
return $this->setUserInfo($username, $role, $details);
}
示例7: ensureUserTable
/**
* Ensure that the user table is presnet, if not attempt to create it
* @returns boolean
*/
protected function ensureUserTable()
{
//initialize the user tables
$init = I2CE::getUserAccessInit('DEFAULT');
if (empty($init)) {
$options = array();
} else {
$options = json_decode($init, true);
if (!is_array($options)) {
I2CE::raiseError("Invalid user access initilization string for Default");
$options = array();
}
}
$options = self::ensureDefaultOptions($options);
$db = MDB2::singleton();
$qry = 'CREATE TABLE IF NOT EXISTS ' . $options['user_table'] . ' ' . '(`id` int(11) NOT NULL auto_increment,' . ' `username` varchar(20) NOT NULL,' . ' `role` varchar(255) collate utf8_bin NOT NULL,' . ' PRIMARY KEY (`id`),' . ' UNIQUE KEY `username` (`username`)' . ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin';
I2CE::raiseError("Initializing LDA-DB User Table. Users' details table se stored in database {$options['userDB']}");
if (I2CE::pearError($db->query($qry), "Cannot create user access table: {$qry}")) {
I2CE::raiseError("Could not initialize LDAP-DB user table");
return false;
}
return true;
}
示例8: queryLastListCount
/**
* Query the last list count and set it in FormStorage
* @param string $form The form name to set.
*/
protected function queryLastListCount($form)
{
$num_rows = $this->db->queryRow("SELECT FOUND_ROWS() AS num_rows");
if (!I2CE::pearError($num_rows, "Couldn't get total number of results.")) {
I2CE_FormStorage::setLastListCount($form, (int) $num_rows->num_rows);
}
}
示例9: buildReportTree
//.........这里部分代码省略.........
$field = substr($ord, 1);
$all_orders[] = "`{$alias_form}+{$field}` DESC";
} else {
$field = $ord;
$all_orders[] = "`{$alias_form}+{$field}` ASC";
}
}
} elseif ($use_link == '') {
$use_link = $link_field == '' ? $link_field : "{$alias_form}+{$link_field}";
}
}
if (!array_key_exists($form, $formObjs)) {
$formObjs[$form] = I2CE_FormFactory::instance()->createContainer($form);
if (!$formObjs[$form] instanceof I2CE_Form) {
I2CE::raiseError("Could not instantiate {$form}");
return array();
}
}
self::$curr_alias = $report_alias[$ff];
$where[] = $formObjs[$form]->generateWhereClause($limit, array("I2CE_DataTree", "getSQLField"));
}
$where_clause = "";
$order_by = "";
if (count($where) > 0) {
$where_clause = " WHERE " . implode(' AND ', $where);
}
if (count($all_orders) > 0) {
$order_by = " ORDER BY " . implode(',', $all_orders);
}
$qry = "SELECT * FROM {$report_table} {$where_clause} {$order_by}";
$db = MDB2::singleton();
I2CE::raiseMessage($qry);
$res = $db->query($qry);
if (I2CE::pearError($res, "Invalid report data tree query: ")) {
return array();
}
$phonebook = array();
$results = array();
$display_string = array();
$display_copy = $displays;
while ($data = $res->fetchRow()) {
foreach ($displays as $alias => $disp_data) {
$id_field = strtolower($alias . "+id");
if ($data->{$id_field} == null || array_key_exists($data->{$id_field}, $phonebook)) {
continue;
}
$curr = array();
$add_this = false;
if (in_array($disp_data['form'], $forms)) {
$curr['value'] = $data->{$id_field};
$add_this = true;
}
if (!$add_this) {
$check_ok = false;
foreach ($display_copy as $alias_copy => $disp_data_copy) {
if ($alias_copy == $alias) {
$check_ok = true;
continue;
}
if (!$check_ok) {
continue;
}
if (array_key_exists('link_field', $disp_data_copy) && $disp_data_copy['link_field'] != '') {
$link_field_copy = $disp_data_copy['link_field'];
if ($data->{$id_field} == $data->{$link_field_copy}) {
$add_this = true;
示例10: mail_pear
protected static function mail_pear($recipients, $headers, $body, $html = false, $attachments = array())
{
try {
if ($html || count($attachments) > 0) {
//$headers['Content-Type'] = 'multipart/mixed';
$mime = new Mail_mime(array('eol' => "\n", 'text_charset' => 'UTF-8', 'html_charset' => 'UTF-8'));
//array('eol' => "\n"));
//I2CE::raiseError($html);
$mime->setHTMLBody($html);
$mime->setTXTBody($body);
foreach ($attachments as $attachment) {
$mime->addAttachment($attachment['data'], $attachment['type'], $attachment['name'], false);
}
$body = $mime->get();
$headers = $mime->headers($headers);
//adapted from http://pear.php.net/manual/en/package.mail.mail-mime.example.php#10541
// $boundary = array();
// preg_match("/boundary=\"(.[^\"]*)\"/e", $headers["Content-Type"], $boundary);
// //echo "<pre>"; var_dump($headers); var_dump($boundary); die();
// $boundary = $boundary[1];
// $boundaryNew = uniqid() ;
// $headers["Content-Type"] = preg_replace('/boundary="(.[^"]*)"/', 'boundary="' . $boundaryNew . '"', $headers["Content-Type"]);
// $body = preg_replace("/^\-\-" . $boundary . "/s", "--" . $boundaryNew, $body);
// $body = preg_replace("/" . $boundary . "--$/s", $boundaryNew . "--", $body);
// $body = preg_replace("/" . $boundary . "--(\s*)--" . $boundary . "/s", $boundary . "--$1--" . $boundaryNew, $body);
// // Workaround, because "\r" breaks the e-mails (possibly a problem with Pear::Mail_Mime and Postfix)
// foreach($headers as $key=>$header) {
// $headers[$key] = str_replace("\r\n", "\n", $header);
// }
}
$result = self::$pear_mailer->send($recipients, $headers, $body);
if (I2CE::pearError($result, "Could not send message via pear mailer")) {
return false;
}
} catch (Exception $e) {
I2CE::raiseError("Could not send message via pear mailer:\n" . $e->getMessage());
return false;
}
return true;
}
示例11: buildDataTree
//.........这里部分代码省略.........
$skip_links[$alias_form . '+' . $link_field] = $link_alias . '+' . $skip_link_fields[$link_alias];
}
}
}
}
} else {
I2CE::raiseMessage("Not sure what to link for {$form} {$link_field} so guessing.");
$join_ons[] = "`{$alias_form}`.`{$link_field}` = `" . $prev_form['alias'] . "`.`id`";
}
if (count($join_ons) > 0) {
$froms[$alias_form] .= " ON (" . implode(' OR ', $join_ons) . ") ";
} else {
I2CE::raiseError("Don't know how to join on {$form} {$link_field}");
return array();
}
}
foreach ($field_list as $field) {
$selects[] = "`{$alias_form}`.`{$field}` AS `{$alias_form}+{$field}`";
}
$prev_form = array('form' => $form, 'alias' => $alias_form);
$form_aliases[$form][] = $alias_form;
}
$or_wheres = array();
foreach ($forms as $selectable) {
if (array_key_exists($selectable, $form_aliases)) {
foreach ($form_aliases[$selectable] as $required_form) {
$or_wheres[] = "`{$required_form}`.`id` IS NOT NULL";
}
}
}
$join_query = "SELECT " . implode(',', $selects) . " FROM " . implode('', $froms) . (count($or_wheres) > 0 ? " WHERE " . implode(' OR ', $or_wheres) : "") . (count($all_orders) > 0 ? " ORDER BY " . implode(',', $all_orders) : "");
//I2CE::raiseMessage( $join_query );
$res = $this->db->query($join_query);
if (I2CE::pearError($res, "Bad query -- {$join_query}")) {
return array();
}
$prev_ids = array();
$results = array();
$phonebook = array();
$display_string = array();
foreach ($displays as $fix_link_alias => &$fix_link_disp_data) {
if (array_key_exists('link_field', $fix_link_disp_data) && $fix_link_disp_data['link_field'] != '') {
$full_link_field = strtolower($fix_link_alias . "+" . $fix_link_disp_data['link_field']);
while (array_key_exists($full_link_field, $skip_links)) {
$full_link_field = $skip_links[$full_link_field];
}
$fix_link_disp_data['link_field'] = $full_link_field;
}
}
$display_copy = $displays;
while ($data = $res->fetchRow()) {
unset($prev_disp);
foreach ($displays as $alias => $disp_data) {
$id_field = strtolower($alias . "+id");
if ($data->{$id_field} == null || array_key_exists($data->{$id_field}, $phonebook)) {
continue;
}
$curr = array();
$add_this = false;
if (in_array($disp_data['form'], $forms)) {
$curr['value'] = $data->{$id_field};
$add_this = true;
}
if (!$add_this) {
$check_ok = false;
foreach ($display_copy as $alias_copy => $disp_data_copy) {
示例12: storeHistory
/**
* Store the history for a form
* I2CE_Form $form
*
*/
public function storeHistory($form)
{
if (!$form instanceof I2CE_Form) {
I2CE::raiseError("Not a form");
return false;
}
if ($form->getId() == '0' || $form->getId() == '') {
I2CE::raiseError("Invalid form id");
return false;
}
$db = MDB2::singleton();
if (!$this->store_stmt) {
$this->store_stmt = $db->prepare("INSERT INTO form_history (formid,history,date,version) VALUES (?,?,NOW(),1)", array('text', 'blob'), MDB2_PREPARE_MANIP);
if (I2CE::pearError($this->store_stmt, "Could prepare store statment")) {
return false;
}
}
$form->populateHistory();
$history = $form->getHistory(true);
if (!is_array($history) || count($history) == 0) {
I2CE::raiseError("No history");
return false;
}
$this->recursiveEncode64($history);
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$history = json_encode($history, JSON_FORCE_OBJECT);
} else {
$history = json_encode($history);
}
$formID = $form->getFormID();
if (I2CE::pearError($this->store_stmt->execute(array($formID, $history)), "Could not store form data for {$formID}")) {
return false;
}
return true;
}
示例13: evaluateFunction
/**
* Evaluate a given relationship function on the given form data
* @param string $funciton
* @param array $formData of I2CE_Form as returend by the @getFormsSatisfyingRelationship()
* @param boolean $displayValue. Defaults to true, in which case it returns the display value of the function. If false, it returns the DB value
* @returns string
*/
public function evaluateFunction($function, $formData, $displayValue = true)
{
//this DOES NOT handle dependent functions.
$details = $this->getFunctionDetails($function);
if (!is_array($details) || !array_key_exists($function, $details) || !is_array($details[$function])) {
return '';
}
$details = $details[$function];
$tmp_table = "`tmp_rel_func_eval_" . $this->relationship . '+' . $function . "`";
$fieldDefs = array();
$fieldVals = array();
foreach ($details['required_fields'] as $formfield) {
list($namedform, $field) = array_pad(explode("+", $formfield, 2), 2, '');
if (!$namedform || !$field || !$formData) {
I2CE::raiseError("{$formfield} not found in form data");
return '';
}
if ($namedform == $this->relationship) {
$namedform = 'primary_form';
}
if (!array_key_exists($namedform, $formData) || !$formData[$namedform] instanceof I2CE_Form) {
I2CE::raiseError("{$namedform} is not in form data");
return '';
}
$fieldObj = $formData[$namedform]->getField($field);
if (!$fieldObj instanceof I2CE_FormField) {
I2CE::raiseError("Invalid field {$field} for named form {$namedform}");
return '';
}
$fieldDefs[] = '`' . $formfield . "` " . $fieldObj->getDBType();
$fieldVals[] = "'" . addslashes($fieldObj->getDBValue()) . "'";
}
$qrys = array("CREATE TEMPORARY TABLE IF NOT EXISTS {$tmp_table} (" . implode(",", $fieldDefs) . ") ", "TRUNCATE {$tmp_table}", "INSERT INTO {$tmp_table} VALUES( " . implode(",", $fieldVals) . ")");
$db = MDB2::singleton();
foreach ($qrys as $qry) {
$res = $db->exec($qry);
if (I2CE::pearError($res, "Could not evaluate {$qry}")) {
return '';
}
}
$qry = 'SELECT ' . $details['qry'] . ' AS res FROM ' . $tmp_table;
$res = $db->queryRow($qry);
if (I2CE::pearError($res, "Could not evaluate {$qry}")) {
return '';
}
//$db->exec("DROP TABLE $tmp_table");
$details['field']->setFromDB($res->res);
if ($displayValue) {
return $details['field']->getDisplayValue();
} else {
return $details['field']->getDBValue();
}
}
示例14: update_keys
protected function update_keys()
{
$db = MDB2::singleton();
$qry = 'TRUNCATE TABLE csd_cache';
if (I2CE::pearError($db->exec($qry), "Error truncatingo csd_cache")) {
return false;
}
$qry = 'ALTER TABLE csd_cache ADD UNIQUE KEY `unique` (`record`,`relationship`,`transform`)';
if (I2CE::pearError($db->exec($qry), "Error adding unique key to csd_cache")) {
return false;
}
return true;
}
示例15: processResults
/**
* Process results
* @param array $results_data an array of results. indices are 'results' and MDB2 Buffered result and 'num_results' the
* number of results. (these values may be false on failure)
* @param DOMNode $contentNode. Default to null a node to append the results onto
* @return boolean
*/
protected function processResults($results_data, $contentNode = null)
{
if (!$results_data['num_results']) {
$this->noData($contentNode);
return true;
}
$too_much = 1000;
I2CE::getConfig()->setIfIsSet($too_much, "/modules/CustomReports/displays/CrossTab/too_much");
if ($results_data['num_results'] > $too_much) {
$this->tooMuchData($contentNode);
return true;
}
$this->template->addHeaderLink("customReports_display_Default.css");
$tableContainerNode = $this->template->appendFileByNode("customReports_display_CrossTab_table.html", "div", $contentNode);
if (!$tableContainerNode instanceof DOMNode) {
I2CE::raiseError("Could not add table container template");
return false;
}
$reportBodyNode = $this->template->getElementById('report_body', $tableContainerNode);
if (!$reportBodyNode instanceof DOMNode) {
I2CE::raiseError("Could not find report body");
return false;
}
$this->data = array();
$left = array();
$top = array();
$this->headers = array();
$displayOrder = '';
if (array_key_exists('display_order', $this->defaultOptions) && $this->defaultOptions['display_order']) {
$displayOrder = $this->defaultOptions['display_order'];
} else {
$this->config->setIfIsSet($displayOrder, 'display_order');
}
$displayOrderArr = explode(',', $displayOrder);
foreach ($this->defaultOptions['displayFieldsTab'] as $reportfield => $side) {
if (!in_array($reportfield, $displayOrderArr)) {
$displayOrderArr[] = $reportfield;
}
if ($side == self::CROSSTAB_LEFT) {
$left[] = $reportfield;
} elseif ($side == self::CROSSTAB_TOP) {
$top[] = $reportfield;
}
}
$left = array_intersect($displayOrderArr, $left);
$top = array_intersect($displayOrderArr, $top);
$total = 'Total';
I2CE::getConfig()->setIfIsSet($total, "/modules/CustomReports/text/headers/count");
$num_results = 0;
while ($row = $results_data['results']->fetchRow()) {
if (I2CE::pearError($row, "Error getting cross tab results: ")) {
$results_data['results']->free();
return false;
}
$mapped_row = $this->mapResults($row);
$left_arr = array();
foreach ($left as $left_field) {
$left_arr[$left_field] = $mapped_row[$left_field];
$this->headers[$left_field] = true;
}
$left_key = json_encode($left_arr);
if (!array_key_exists($left_key, $this->data)) {
$this->data[$left_key] = array();
$num_results++;
}
if (!array_key_exists('total', $this->data)) {
$this->data['total'] = array();
$num_results++;
}
$data_row =& $this->data[$left_key];
foreach ($top as $top_field) {
if (!array_key_exists($top_field, $data_row)) {
$data_row[$top_field] = array();
}
if (!array_key_exists($top_field, $this->headers)) {
$this->headers[$top_field] = array();
}
$this->headers[$top_field][$mapped_row[$top_field]] = true;
if (!array_key_exists($mapped_row[$top_field], $data_row[$top_field])) {
$data_row[$top_field][$mapped_row[$top_field]] = $mapped_row['total'];
} else {
$data_row[$top_field][$mapped_row[$top_field]] += $mapped_row['total'];
}
if (!array_key_exists($total, $data_row[$top_field])) {
$data_row[$top_field][$total] = $mapped_row['total'];
} else {
$data_row[$top_field][$total] += $mapped_row['total'];
}
if (!array_key_exists($top_field, $this->data['total'])) {
$this->data['total'][$top_field] = array();
}
if (!array_key_exists($mapped_row[$top_field], $this->data['total'][$top_field])) {
$this->data['total'][$top_field][$mapped_row[$top_field]] = $mapped_row['total'];
//.........这里部分代码省略.........