public function query($q, $resultmode=MYSQLI_STORE_RESULT) { if($this->live_log) echo $this->highlight_query($q).$this->colors['after_q']; $before = microtime(true); $r = parent::query($q, $resultmode); $after = microtime(true); $info = $this->info; $w = parent::query("SHOW WARNINGS"); $warnings = array(); if($w) while($wr = $w->fetch_assoc) $warnings[] = $wr; $log = array( 'query' => $q, 'time' => $after - $before, 'info' => $info, 'info_arr' => self::parse_info($info), 'warnings' => $warnings, 'error' => $this->error, 'errno' => $this->errno, 'affected_rows' => $this->affected_rows, 'insert_id' => $this->insert_id, 'num_fields' => is_bool($r) ? 0 : $r->num_fields, 'num_rows' => is_bool($r) ? 0 : $r->num_rows, ); if($this->keep_log) $this->query_log[] = $log; if($this->live_log) { printf("%s%04fs, %s%s%s", $this->colors['before_info'], $log['time'], $info, $this->colors['after_info'], $this->colors['after_q']); foreach($warnings as $warn) { echo $this->colors['before_warn'] . "Level $warn[Level] warning: $warn[Message] ($warn[Code])". $this->colors['after_warn'] . $this->colors['after_q']; } } if($this->file_log) { $f = fopen($this->file_log, "a"); fputs($f, array_export($log, true) . ";\n"); fclose($f); } if($r) return $r; throw new Exception("Query failed. ".var_export($log, true)); }
public function get_cell_ds($vvv, $v) { $html = ''; if ($vvv['using_block'] && $vvv['block_id']) { $html .= '$__cell_data[\'' . $vvv['id'] . '\'] = web_get_block(\'' . $vvv['block_id'] . '\',\'' . $this->page_info['tem_material_url'] . '/' . $this->settings['template_name'] . '/icon/' . '\');'; $this->cell_ds_is_loaded[$vvv['id']] = true; } else { if ($vvv['data_source'] == $v) { //引入数据源 $html .= 'include_once(M2O_ROOT_PATH.\'include/' . $v . '.php\');'; $html .= '$ds_' . $v . ' = new ' . 'ds_' . $v . '();'; //执行数据源:1.取单元设置的参数 2.取该数据源依赖其他数据源的参数 $html .= '$__cell_data[\'' . $vvv['id'] . '\'] = web_compare_cell_content(\'' . $vvv['id'] . '\',$ds_' . $v . '->show(' . array_export($this->cell_ds[$vvv['id']]) . '));'; //样式默认数据 $html .= 'if(!$__cell_data[\'' . $vvv['id'] . '\'] || !is_array($__cell_data[\'' . $vvv['id'] . '\'])) { if(' . var_export($this->cell_set[$vvv['id']]['mode_detail']['default_param'], true) . ' && is_array(' . var_export($this->cell_set[$vvv['id']]['mode_detail']['default_param'], true) . ')) { $__cell_data[\'' . $vvv['id'] . '\'] = ' . var_export($this->cell_set[$vvv['id']]['mode_detail']['default_param'], true) . '; } else { $__cell_data[\'' . $vvv['id'] . '\'] = array(); } }'; $html .= $this->out_param($vvv); if ($vvv['mode_detail']['mode_type'] == 1) { //正文数据源,取内容标题关键字描述 $html .= '$__info[\'__pagetitle\'] = $__info[\'__pagetitle\']?$__info[\'__pagetitle\']:$__cell_data[\'' . $vvv['id'] . '\'][0][\'title\']; $__info[\'__pagekeyword\'] = $__info[\'__pagekeyword\']?$__info[\'__pagekeyword\']:$__cell_data[\'' . $vvv['id'] . '\'][0][\'keyword\']; $__info[\'__pagedescription\'] = $__info[\'__pagedescription\']?$__info[\'__pagedescription\']:$__cell_data[\'' . $vvv['id'] . '\'][0][\'brief\'];'; } $this->cell_ds_is_loaded[$vvv['id']] = true; } } //如果没有选择数据源 则用样式里默认数据 if (!$vvv['data_source']) { $html .= 'if(is_array(' . var_export($this->cell_set[$vvv['id']]['mode_detail']['default_param'], true) . ')) { $__cell_data[\'' . $vvv['id'] . '\'] = ' . var_export($this->cell_set[$vvv['id']]['mode_detail']['default_param'], true) . '; } else { $__cell_data[\'' . $vvv['id'] . '\'] = array(); }'; if ($vvv['mode_detail']['mode_type'] == 1) { //正文数据源,取内容标题关键字描述 $html .= '$__info[\'__pagetitle\'] = $__info[\'__pagetitle\']?$__info[\'__pagetitle\']:$__cell_data[\'' . $vvv['id'] . '\'][0][\'title\']; $__info[\'__pagekeyword\'] = $__info[\'__pagekeyword\']?$__info[\'__pagekeyword\']:$__cell_data[\'' . $vvv['id'] . '\'][0][\'keyword\']; $__info[\'__pagedescription\'] = $__info[\'__pagedescription\']?$__info[\'__pagedescription\']:$__cell_data[\'' . $vvv['id'] . '\'][0][\'brief\'];'; } $this->cell_ds_is_loaded[$vvv['id']] = true; } return $html; }