| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -4,29 +4,26 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 * | 
					 | 
					 | 
					 | 
					 * | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | 
					 | 
					 | 
					 | 
					 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 * @author  George Pirogov <i1557@yandex.ru> | 
					 | 
					 | 
					 | 
					 * @author  George Pirogov <i1557@yandex.ru> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 * @author  Thomas Hooge <hooge@rowa-group.com> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 * | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 */ | 
					 | 
					 | 
					 | 
					 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// must be run within Dokuwiki | 
					 | 
					 | 
					 | 
					// must be run within Dokuwiki | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					if (!defined('DOKU_INC')) die(); | 
					 | 
					 | 
					 | 
					if (!defined('DOKU_INC')) die(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					/** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 * All DokuWiki plugins to extend the parser/rendering mechanism | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 * need to inherit from this class | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					class syntax_plugin_sqlquery extends DokuWiki_Syntax_Plugin { | 
					 | 
					 | 
					 | 
					class syntax_plugin_sqlquery extends DokuWiki_Syntax_Plugin { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public function getType() { | 
					 | 
					 | 
					 | 
					    public function getType() { return 'substition'; } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return 'substition'; | 
					 | 
					 | 
					 | 
					    public function getSort() { return 666; } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    public function getPType() { return 'block'; } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public function getSort() { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return 666; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public function connectTo($mode) | 
					 | 
					 | 
					 | 
					    public function connectTo($mode) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $this->Lexer->addEntryPattern('<sql>', $mode, 'plugin_sqlquery'); | 
					 | 
					 | 
					 | 
					        $this->Lexer->addSpecialPattern('<sql\b(?:\s+(?:host|db|type)=[\w\-\.$]+?)*\s*>(?:.*?</sql>)', $mode, 'plugin_sqlquery'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public function postConnect() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $this->Lexer->addExitPattern('</sql>','plugin_sqlquery'); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -36,29 +33,36 @@ class syntax_plugin_sqlquery extends DokuWiki_Syntax_Plugin { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param int             $state   The state of the handler | 
					 | 
					 | 
					 | 
					     * @param int             $state   The state of the handler | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param int             $pos     The position in the document | 
					 | 
					 | 
					 | 
					     * @param int             $pos     The position in the document | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param Doku_Handler    $handler The handler | 
					 | 
					 | 
					 | 
					     * @param Doku_Handler    $handler The handler | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return array Data for the renderer | 
					 | 
					 | 
					 | 
					     * @return array Data for the renderer | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public function handle($match, $state, $pos, Doku_Handler $handler) | 
					 | 
					 | 
					 | 
					    public function handle($match, $state, $pos, Doku_Handler $handler) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					        $data = array('state' => $state); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        switch ( $state ) | 
					 | 
					 | 
					 | 
					        if ($state == DOKU_LEXER_SPECIAL) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        { | 
					 | 
					 | 
					 | 
					            # get type (DSN prefix) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              case DOKU_LEXER_ENTER: | 
					 | 
					 | 
					 | 
					            if (preg_match('/<sql\b.*type=(mysql|dblib)/', $match, $result)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              $data = array(); | 
					 | 
					 | 
					 | 
					                $data['type'] = $result[1]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              return $data; | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              break; | 
					 | 
					 | 
					 | 
					                $data['type'] = $this->getConf('type'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              case DOKU_LEXER_UNMATCHED: | 
					 | 
					 | 
					 | 
					            # get host | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        			return array('sqlquery' => $match); | 
					 | 
					 | 
					 | 
					            if (preg_match('/<sql\b.*host=([\w\-\.$]+)/', $match, $result)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              break; | 
					 | 
					 | 
					 | 
					                $data['host'] = $result[1]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              case DOKU_LEXER_EXIT: | 
					 | 
					 | 
					 | 
					                $data['host'] = $this->getConf('Host'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              $data = array(); | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              return $data; | 
					 | 
					 | 
					 | 
					            # get database | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              break; | 
					 | 
					 | 
					 | 
					            if (preg_match('/<sql\b.*db=([\w\-\.$]+)/', $match, $result)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					                $data['db'] = $result[1]; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $data['db'] = $this->getConf('DB'); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            # get query | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $data['match'] = $match; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (preg_match('%<sql.*?>(.*)</sql>%s', $match, $result)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $data['query'] = trim($result[1]); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $data = array(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return $data; | 
					 | 
					 | 
					 | 
					        return $data; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -68,72 +72,73 @@ class syntax_plugin_sqlquery extends DokuWiki_Syntax_Plugin { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param string         $mode      Renderer mode (supported modes: xhtml) | 
					 | 
					 | 
					 | 
					     * @param string         $mode      Renderer mode (supported modes: xhtml) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param Doku_Renderer  $renderer  The renderer | 
					 | 
					 | 
					 | 
					     * @param Doku_Renderer  $renderer  The renderer | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param array          $data      The data from the handler() function | 
					 | 
					 | 
					 | 
					     * @param array          $data      The data from the handler() function | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @return bool If rendering was successful. | 
					 | 
					 | 
					 | 
					     * @return bool If rendering was successful. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     */ | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    public function render($mode, Doku_Renderer $renderer, $data) | 
					 | 
					 | 
					 | 
					    public function render($mode, Doku_Renderer $renderer, $data) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    { | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if ( $mode != 'xhtml' ) return false; | 
					 | 
					 | 
					 | 
					        if ($mode != 'xhtml') return false; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					        if (empty($data['query'])) return true; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if ( !empty( $data['sqlquery'] ) ) | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        { | 
					 | 
					 | 
					 | 
					        // get configuration | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // получаем параметры конфигурации | 
					 | 
					 | 
					 | 
					        $user     = $this->getConf('user'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $host     = $this->getConf('Host'); | 
					 | 
					 | 
					 | 
					        $password = $this->getConf('password'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $DB       = $this->getConf('DB'); | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $user     = $this->getConf('user'); | 
					 | 
					 | 
					 | 
					        // connect to database | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $password = $this->getConf('password'); | 
					 | 
					 | 
					 | 
					        $dsn = "{$data['type']}:host={$data['host']};dbname={$data[db]};charset=UTF-8;"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					        try { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // получаем запрос | 
					 | 
					 | 
					 | 
					            $dbh = new PDO($dsn, $user, $password); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $querystring = $data['sqlquery']; | 
					 | 
					 | 
					 | 
					        } catch (PDOException $e) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					            $renderer->doc .= "<pre>Unable to connect ro database:" . $e->getMessage() . "</pre>\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // подключаемся к базе | 
					 | 
					 | 
					 | 
					            return true; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $link = mysqli_connect($host, $user, $password, $DB); | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            mysqli_set_charset($link, "utf8"); | 
					 | 
					 | 
					 | 
					        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					        $dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // подключились | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if ( $link ) | 
					 | 
					 | 
					 | 
					        // run query | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            { | 
					 | 
					 | 
					 | 
					        try { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                $result = mysqli_query($link, $querystring); | 
					 | 
					 | 
					 | 
					            $result = $dbh->query($data['query']); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if ( $result ) | 
					 | 
					 | 
					 | 
					        } catch (PDOException $e) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                { | 
					 | 
					 | 
					 | 
					            $renderer->doc .= "<pre>Error in query:" . $e->getMessage() . "</pre>\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    // получаем кол-во полей в таблице | 
					 | 
					 | 
					 | 
					            return true; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $fieldcount = mysqli_num_fields($result); | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    // строим таблицу | 
					 | 
					 | 
					 | 
					        // get the number of fields in the table | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $renderer->doc .= "<table id=\"sqlquerytable\" class=\"inline\">"; | 
					 | 
					 | 
					 | 
					        $fieldcount = $result->columnCount(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    // строим заголовок | 
					 | 
					 | 
					 | 
					        // build a table | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $renderer->doc .= "<thead><tr>"; | 
					 | 
					 | 
					 | 
					        $renderer->doc .= '<table id="sqlquerytable" class="inline">' . "\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    while ($fieldinfo = mysqli_fetch_field($result)) | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    { | 
					 | 
					 | 
					 | 
					        // build the header section of the table | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        $renderer->doc .= "<th>"; | 
					 | 
					 | 
					 | 
					        $renderer->doc .= "<thead><tr>"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        $renderer->doc .= $fieldinfo->name; | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        $renderer->doc .= "</th>"; | 
					 | 
					 | 
					 | 
					        for ($i = 0; $i < $fieldcount; $i++) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					            $meta = $result->getColumnMeta($i); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $renderer->doc .= "</tr></thead>"; | 
					 | 
					 | 
					 | 
					            $renderer->doc .= "<th>"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					            $renderer->doc .= $meta['name']; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    // строим содержимое таблицы | 
					 | 
					 | 
					 | 
					            $renderer->doc .= "</th>"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $renderer->doc .= "<tbody>"; | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    while ($row = mysqli_fetch_row($result)) | 
					 | 
					 | 
					 | 
					        $renderer->doc .= "</tr></thead>\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    { | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          $renderer->doc .= "<tr>"; | 
					 | 
					 | 
					 | 
					        // build the contents of the table | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					        $renderer->doc .= "<tbody>\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          // строим строку | 
					 | 
					 | 
					 | 
					        foreach ($result as $row) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          for ( $i = 0; $i < $fieldcount; $i++ ) | 
					 | 
					 | 
					 | 
					            $renderer->doc .= "<tr>"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          { | 
					 | 
					 | 
					 | 
					            for ( $i = 0; $i < $fieldcount; $i++ ) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                              $renderer->doc .= "<td>"; | 
					 | 
					 | 
					 | 
					                $renderer->doc .= "<td>"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                              $renderer->doc .= $row[$i]; | 
					 | 
					 | 
					 | 
					                $renderer->doc .= htmlentities($row[$i]); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                              $renderer->doc .= "</td>"; | 
					 | 
					 | 
					 | 
					                $renderer->doc .= "</td>"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          $renderer->doc .= "</tr>"; | 
					 | 
					 | 
					 | 
					            $renderer->doc .= "</tr>\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } // of while fetch_row | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    // закрываем таблицу | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $renderer->doc .= "</tbody></table>"; | 
					 | 
					 | 
					 | 
					        // finish the table | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } // of mysqli_query | 
					 | 
					 | 
					 | 
					        $renderer->doc .= "</tbody>\n</table>\n"; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                mysqli_close($link); | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } // of mysqli link | 
					 | 
					 | 
					 | 
					        // Close connection, there is no close() method with PDO :-( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } // of sqlquery not empty | 
					 | 
					 | 
					 | 
					        $result = null; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $dbh = null; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return true; | 
					 | 
					 | 
					 | 
					        return true; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } // of render function | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// vim:ts=4:sw=4:et: | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |