ezSQL ของขวัญจากสวรรค์สำหรับชาว PHP*

เริ่มโดย janeos, 04 กันยายน 2007, 09:44:43

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

lowprofile

อ้างถึงจาก: 7 ใน 05 กันยายน 2007, 04:35:04
อืม ขอบคุณคุณโจ้ อยากได้แบบ connect xml แล้วทำงานเหมือน DB เลยอ่ะ 555

หมายถึง XQuery หรือเปล่าครับ? ลองดูตัวนี้นะครับ
http://phpxmlclasses.sourceforge.net/xquery_lite.html

Now we are going to show how some W3C Xquery Use-Cases can be solved using Xquery Lite
In the examples we will work with the "bib.xml" document which has information about books:
อ้างถึง<bib>
    <book year="1994">
        <title>TCP/IP Illustrated</title>
        <author><last>Stevens</last><first>W.</first></author>
        <publisher>Addison-Wesley</publisher>
        <price> 65.95</price>
    </book>

    <book year="1992">
        <title>Advanced XML Programming in the Unix environment</title>
        <author><last>Stevens</last><first>W.</first></author>
        <publisher>Addison-Wesley</publisher>
        <price>65.95</price>
    </book>

    <book year="2000">
        <title>Data on the Web</title>
        <author><last>Abiteboul</last><first>Serge</first></author>
        <author><last>Buneman</last><first>Peter</first></author>
        <author><last>Suciu</last><first>Dan</first></author>
        <publisher>Morgan Kaufmann Publishers</publisher>
        <price> 39.95</price>
    </book>

    <book year="1999">
        <title>The Economics of Technology and Content for Digital TV</title>
        <editor>
               <last>Gerbarg</last><first>Darcy</first>
                <affiliation>CITI</affiliation>
        </editor>
            <publisher>Kluwer Academic Publishers</publisher>
        <price>129.95</price>
    </book>

</bib>

Use-Case 1
อ้างถึง<bib>
{
  for $b in document("c:\apache\htdocs\phpxmlclasses\bib.xml")/bib/book
  where $b/publisher = "Addison-Wesley" and $b/@year > 1991
  return
    <book year="{ $b/@year }">
     { $b/title }
    </book>
}
</bib>

Comment: we retrieve all book elements using a for statement and filter by the name of the published and the year attribute (note the element/@name notation). The return just builds an XML document listing the year as an attribute and the title of the books that match the criteria.

The result will be something like this:

อ้างถึง<bib>
<book year="1994">
<title>TCP/IP Illustrated</title>
</book>
<book year="1992">
<title>Advanced XML Programming in the Unix environment</title>
</book>
</bib>


อันนี้เหมาะกับการจัดการ xml --> xml นะครับ ถ้าต้องการ xml --> data คงต้องทำตามที่คุณ EThaiZone แนะนำครับผม
ชีวิตนี้น้อยนัก

๏ พายเถิดพ่ออย่ารั้ง   รอพาย
จวนตะวันจักสาย   ส่องฟ้า
ของสดสิ่งควรขาย   จักขาด ค่าแฮ
ตลาดเลิกแล้วอ้า   บ่นอื้นเอาใคร ๚ะ๛


คราวนี้เป็นคราวเงินหมด
ธนาคาร : ไทยพาณิชย์ จำกัด (มหาชน) สาขา : อุดรธานี
ชื่อบัญชี : โครงการช่วยชาติโดยหลวงตามหาบัว ญาณสัมปันโน
เลขที่บัญชี : 510-2-83957-5

hunter

ทำการใหญ่ ใจต้องนิ่ง

7

โอ้ว สุดยอดเลย ขอบคุณทั้ง 2 มากๆ

gootooyoo

 :wanwan004:เมื่อก่อนเคยเขียน class เองบ้างครับ แต่เริ่ม php เริ่มหลายverstion และต้องทำงาน อื่นอีกเลย ไม่ค่อยได้เขียน หัดใช้ของฟรีบ้างก็ดีครับชอบคุณ :wanwan016:
ขวากหนาม ที่เราต้องข้ามผ่าน ถึงจะเจ็บก็จะไป (\◣_◢/)  [direct=http://gootooyoo.blogspot.com] [/direct]
[direct=http://gootooyoo.blog.com] ❤ [direct=http://free-icons.blogspot.com] ❤  [direct=http://goo-dog.blogspot.com]❤

ohmohm

ไหนๆ ก็ขุดแล้ว แล้วไปเจอมาพอดี พัฒนาโปรแกรมง่ายๆ ไร้ SQL ด้วยเทคนิค O/R mapping ( Java นะ ไม่รู้ php มีไหม )
http://www.narisa.com/forums/index.php?app=blog&module=display&section=blog&blogid=30&showentry=2334