[Codeigniter-users] XMLの生成について xml_from_result v2.0.3

Back to archive index

yfa76550 yfa76****@nifty*****
2012年 1月 14日 (土) 11:07:19 JST


$B8MED$5$s(B
$BM-$jFq$&$4$6$$$^$9!#(B
$BD:$$$?(B2$B9T$G!"I=<(=PMh$^$7$?!#(B
$B3NG'$O!"%V%i%&%6!J(BIE, chrome, firefox)$B$G$9!#A4$FF10l$N(B1$B9T$G$7$?!#(B
$B!!(Bv1.6/1.7$B$O??$CGr2hLL!J(Bcsv$B$O @ 5>o!K$G$9$,!"NI$7$H$7$F!#!#(B
$B$3$NEz$($r8+$D$1$k$N$KAjEv$J;~4V$,$+$C$F$$$?!"$H;W$$$^$9!#(B
$B=u$+$j$^$7$?!"$*Ni?=$7>e$2$^$9!#(B

----------$B!!(BOriginal Message$B!!(B----------
From:     $B8MED!!9-(B <info****@sciss*****>
To:       codei****@lists*****
Sent:     Sat, 14 Jan 2012 00:39:01 +0900
Subject:  Re: [Codeigniter-users] XML$B$N @ 8@.$K$D$$$F!!(Bxml_from_result v2.0.3

>$B$3$s$P$s$O!"8MED$G$9!#(B
>
>> $B7k2L$O!"0J2<$NMM$K!"2~9T$,$5$l$:!"%?%0$bIU$-$^$;$s!#(B
>> 1 $B%j%s%4(B $B=)(B $B%P%i2J(B 2012-01-11 01:14:52 2 $B%&%s%7%e%&%_%+%s(B $BE_(B $B%_%+%s2J(B 2012-01-11 01:14:52 3 $B%V%I%&(B $B=)(B $B%V%I%&2J(B 2012-
>> 01-
>
>$B=PNO7k2L$N(BXML$B$O2?$G3NG'$5$l$F$$$^$9$+!)(B Web$B%V%i%&%6!<$G$7$g$&$+!)(B
>$B<j85$N(BCI 2.0.3$B4D6-$G%3!<%I$rE>5-$7$F;n$7$F$_$^$7$?$,!"(B
>$BJV$C$F$-$?7k2L$O(BXML$B7A<0$K$J$C$F$$$^$9!#(B
>
>$B:G8e$N(BXML$B=PNO$r!"(Becho$BJ8$G$O$J$/!"(B
>$B$?$H$($P<!$N$h$&$K(BMIME$B%?%$%W$,(BXML$B$G$"$k$3$H$r(B
>$BL@<($7$F=PNO$7$?>l9g$O$I$N$h$&$J7k2L$K$J$j$^$9$G$7$g$&$+!)(B
>
>	$this->output->set_content_type('xml');
>	$this->output->set_output($this->dbutil->xml_from_result($query, $config));
>
>
>$B0J>e$G$9!#(B
>
>
>
>On 2012/01/13, at 18:37, yfa76550 wrote:
>
>> $B7*ED$G$9!#(B
>> $B?'!9C5$7$?$j!";n9T:x8m$7$F$_$^$7$?$,!"$I$&$7$F$b=PMh$^$;$s!#(B
>> $B$I$J$?$+%"%I%P%$%9D:$1$^$;$s$+!)(B
>> $B$3$N>l$G!"$3$&$$$&<ALd$,$^$:$1$l$P!"E,Ev$J%5%$%H$r$*65$(2<$5$$!#(B
>> 
>> ===
>> 
>> $B!IE0Dl!I$NK\$K$"$k%5%s%W%k-!(B(chapter 11 - dbutil2.php)$B$r$=$N$^$^%$%s%]!<%H$7$?$N$G$9$,!"(B
>> $B7k2L$O!"0J2<$NMM$K!"2~9T$,$5$l$:!"%?%0$bIU$-$^$;$s!#(B
>> 1 $B%j%s%4(B $B=)(B $B%P%i2J(B 2012-01-11 01:14:52 2 $B%&%s%7%e%&%_%+%s(B $BE_(B $B%_%+%s2J(B 2012-01-11 01:14:52 3 $B%V%I%&(B $B=)(B $B%V%I%&2J(B 2012-
>> 01-
>> 
>> $B$=$NA0$N%5%s%W%k(B(chapter 11 - dbutil1.php$B!K!!(Bcsv_from_result$B!!$N7k2L$O0J2<$NMM$K(BOK$B$J$N$G!"(B
>> $B4pK\E*$J=j$OLdBj$J$$$N$+$H;W$$$^$9!#(B
>> ($BC"$7!"(Bv1,6$B$d(Bv1.7$B$G$O!"(Bcsv$B$b2~9T$5$l$:(B1$B9TI=5-!"%?%0$O$D$-$^$9$,!#!#!K(B
>> "id","name","season","family","modified",
>> "1","$B%j%s%4(B","$B=)(B","$B%P%i2J(B","2012-01-11 01:14:52",
>> "2","$B%&%s%7%e%&%_%+%s(B","$BE_(B","$B%_%+%s2J(B","2012-01-11 01:14:52",
>> 
>> $B-!%5%s%W%k$N<L$7$G$9!#(BCI_$BIU2C(B
>> <?php
>> /*
>> * $B%G!<%?%Y!<%9%f!<%F%#%j%F%#%/%i%9(B $BMxMQNc(B2
>> * XML$B$N @ 8@.(B
>> */
>> 
>> class Dbutil2 extends CI_Controller {
>> 
>> 	function index()
>> 	{
>> 		// $B%G!<%?%Y!<%9%f!<%F%#%j%F%#%/%i%9$N%m!<%I(B
>> 		$this->load->dbutil();
>> 
>> 		// $B8!:w(B
>> 		$query = $this->db->query("SELECT * FROM fruits");
>> 
>> 		// XML$B$N @ _Dj(B
>> 		$config = array (
>>                  'root'    => 'root',
>>                  'element' => 'element',
>>                  'newline' => "\n",
>>                  'tab'     => "\t"
>>                );
>> 
>> 		// XML$B$N=PNO(B
>> 		echo $this->dbutil->xml_from_result($query, $config);
>> 	}
>> 
>> }
>> ?>
>> 
>> $B-"%@%&%s%m!<%I$7$?!!(Bsystem\database\DB_utility.php$B!!$N<L$7$G$9!#(B
>> xml_from_result$B!!$N$H$3$m$NH4?h(B
>> 
>> 	/**
>> 	 * Generate XML data from a query result object
>> 	 *
>> 	 * @access	public
>> 	 * @param	object	The query result object
>> 	 * @param	array	Any preferences
>> 	 * @return	string
>> 	 */
>> 	function xml_from_result($query, $params = array())
>> 	{
>> 		if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
>> 		{
>> 			show_error('You must submit a valid result object');
>> 		}
>> 
>> 		// Set our default values
>> 		foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => 
>> $val)
>> 		{
>> 			if ( ! isset($params[$key]))
>> 			{
>> 				$params[$key] = $val;
>> 			}
>> 		}
>> 
>> 		// Create variables for convenience
>> 		extract($params);
>> 
>> 		// Load the xml helper
>> 		$CI =& get_instance();
>> 		$CI->load->helper('xml');
>> 
>> 		// Generate the result
>> 		$xml = "<{$root}>".$newline;
>> 		foreach ($query->result_array() as $row)
>> 		{
>> 			$xml .= $tab."<{$element}>".$newline;
>> 
>> 			foreach ($row as $key => $val)
>> 			{
>> 				$xml .= $tab.$tab."<{$key}>".xml_convert($val)."</{$key}>".$newline;
>> 			}
>> 			$xml .= $tab."</{$element}>".$newline;
>> 		}
>> 		$xml .= "</$root>".$newline;
>> 
>> 		return $xml;
>> 	}
>> 
>> $B$A$J$_$K!"(BcodeIgniter$B$r;H$o$:$K!"(BPEAR$B$N!I(BXML/Serializer.php$B!I$G!"JL$N%9%/%j%W%H$G$d$k$H!"(BXML$B$, @ 8@.=PMh$^$9$,!"(B
>> PEAR$B$r(BcodeIgniter$B$K%$%s%]!<%H$7$F<B9T$9$k$H!"2~9T!&%?%0$J$7!"$H$J$j$^$9!#(B
>> PEAR$B$NB>$N4X?t!J(BSpreadsheet_Excel_Writer$B!K$O(BOK$B$J$N$G!"$3$l$b2?$+HyL/$J=j$,860x$+$H!#(B
>> 
>> $BD9J8$G$9$_$^$;$s!#(B
>> $B59$7$/$*4j$$CW$7$^$9!#(B
>> 
>> _______________________________________________
>> Codeigniter-users mailing list
>> Codei****@lists*****
>> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Codeigniter-users mailing list
>Codei****@lists*****
>http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>
>
>---html-part included links-------
>mailto:Codei****@lists*****




Codeigniter-users メーリングリストの案内
Back to archive index