protected function query_and_fetch_records($sql, $index_by_id) { $result = $this->conn->select($sql); if (kernel::is_debug()) { debug::save('rdb', $sql); } if ($result === false) { throw new server_except("select error: " . $this->conn->last_error() . " sql: {$sql}"); } $records = []; if ($index_by_id) { while (($record = $result->fetch_record()) !== null) { $records[(int) $record['id']] = $record; } } else { while (($record = $result->fetch_record()) !== null) { $records[] = $record; } } $result->free(); return $records; }
protected static function do_render_in($_view_dir, $_pps_type, target $_target) { foreach ($_target->get_param('link', []) as $_linked_name) { $_file = $_pps_type . '/' . $_linked_name . '.' . $_pps_type; $_pps_file = $_view_dir . '/' . $_file; if (is_readable($_pps_file)) { if (kernel::is_debug()) { echo "\n/******** {$_file} ********/\n\n"; } require $_pps_file; } } $_layout_name = $_target->get_param('layout', ''); if ($_layout_name !== '') { $_file = 'layout/' . $_layout_name . '.' . $_pps_type; $_pps_file = $_view_dir . '/' . $_file; if (is_readable($_pps_file)) { if (kernel::is_debug()) { echo "\n/******** {$_file} ********/\n\n"; } require $_pps_file; } } foreach ($_target->get_param('block', []) as $_block_name) { $_file = 'block/' . $_block_name . '.' . $_pps_type; $_pps_file = $_view_dir . '/' . $_file; if (is_readable($_pps_file)) { if (kernel::is_debug()) { echo "\n/******** {$_file} ********/\n\n"; } require $_pps_file; } } if ($_target->get_target_name() !== '') { $_file = 'page/' . $_target->get_target_file('.' . $_pps_type); $_pps_file = $_view_dir . '/' . $_file; if (is_readable($_pps_file)) { if (kernel::is_debug()) { echo "\n/******** {$_file} ********/\n\n"; } require $_pps_file; } } }
protected function execute($sql) { $result = mysqli_query($this->conn, $sql); if (kernel::is_debug()) { debug::save('session', $sql); } if ($result === false) { throw new server_except("except: {$sql}"); } }