本文整理汇总了PHP中Objects::getColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Objects::getColumns方法的具体用法?PHP Objects::getColumns怎么用?PHP Objects::getColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::getColumns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadRow
/**
* Load row from database based on ID
*
* @access public
* @param mixed $id
* @return array
*/
function loadRow($id)
{
$ocols = Objects::getColumns();
$tcols = $this->getColumns();
$columns = array_map('db_escape_field', array_merge($ocols, $tcols));
$table_prefix = defined('FORCED_TABLE_PREFIX') && FORCED_TABLE_PREFIX ? FORCED_TABLE_PREFIX : TABLE_PREFIX;
$sql = sprintf("\r\n \t\tSELECT %s \r\n \t\tFROM %s\tINNER JOIN `" . $table_prefix . "objects` o\r\n \t\tON o.id = %s.object_id \r\n \t\tWHERE %s", implode(', ', array_merge($columns)), $this->getTableName(true), $this->getTableName(true), $this->getConditionsById($id));
// sprintf
$ocols = null;
$tcols = null;
$columns = null;
return DB::executeOne($sql);
}
示例2: executeReport
/**
* Execute a report and return results
*
* @param $id
* @param $params
*
* @return array
*/
static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset = 0, $limit = 50, $to_print = false)
{
if (is_null(active_context())) {
CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context')));
}
$results = array();
$report = self::getReport($id);
$show_archived = false;
if ($report instanceof Report) {
$conditionsFields = ReportConditions::getAllReportConditionsForFields($id);
$conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id);
$ot = ObjectTypes::findById($report->getReportObjectTypeId());
$table = $ot->getTableName();
if ($ot->getType() == 'dimension_object' || $ot->getType() == 'dimension_group') {
$hook_parameters = array('report' => $report, 'params' => $params, 'order_by_col' => $order_by_col, 'order_by_asc' => $order_by_asc, 'offset' => $offset, 'limit' => $limit, 'to_print' => $to_print);
$report_result = null;
Hook::fire('replace_execute_report_function', $hook_parameters, $report_result);
if ($report_result) {
return $report_result;
}
}
eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();");
eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();');
$order_by = '';
if (is_object($params)) {
$params = get_object_vars($params);
}
$report_columns = ReportColumns::getAllReportColumns($id);
$allConditions = "";
$contact_extra_columns = self::get_extra_contact_columns();
if (count($conditionsFields) > 0) {
foreach ($conditionsFields as $condField) {
if ($condField->getFieldName() == "archived_on") {
$show_archived = true;
}
$skip_condition = false;
$model = $ot->getHandlerClass();
$model_instance = new $model();
$col_type = $model_instance->getColumnType($condField->getFieldName());
$allConditions .= ' AND ';
$dateFormat = 'm/d/Y';
if (isset($params[$condField->getId()])) {
$value = $params[$condField->getId()];
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
$dateFormat = user_config_option('date_format');
}
} else {
$value = $condField->getValue();
}
if ($ot->getHandlerClass() == 'Contacts' && in_array($condField->getFieldName(), $contact_extra_columns)) {
$allConditions .= self::get_extra_contact_column_condition($condField->getFieldName(), $condField->getCondition(), $value);
} else {
if ($value == '' && $condField->getIsParametrizable()) {
$skip_condition = true;
}
if (!$skip_condition) {
$field_name = $condField->getFieldName();
if (in_array($condField->getFieldName(), Objects::getColumns())) {
$field_name = 'o`.`' . $condField->getFieldName();
}
if ($condField->getCondition() == 'like' || $condField->getCondition() == 'not like') {
$value = '%' . $value . '%';
}
if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) {
if ($value == date_format_tip($dateFormat)) {
$value = EMPTY_DATE;
} else {
$dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value);
$value = $dtValue->format('Y-m-d');
}
}
if ($condField->getCondition() != '%') {
if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) {
$allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
} else {
if ($condField->getCondition() == '=' || $condField->getCondition() == '<=' || $condField->getCondition() == '>=') {
if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) {
$equal = 'datediff(' . DB::escape($value) . ', `' . $field_name . '`)=0';
} else {
$equal = '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
}
switch ($condField->getCondition()) {
case '=':
$allConditions .= $equal;
break;
case '<=':
case '>=':
$allConditions .= '(`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value) . ' OR ' . $equal . ') ';
break;
}
} else {
$allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value);
//.........这里部分代码省略.........