SQL ve FQL Etiketleri

0

Tarih : 09-11-2009 | Yazan : Hüseyin Bora | Kategori : FDL, Faces ORM, PHP, PHP Faces, PHP ORM

SQL etiketi query niteliğine paremetre olarak verilen SQL sorgusu işletir ve id niteliğine verilen isim ile bir sonuc kümesi getirir.

Örnek

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<@import prefix="sql" taglib="phpf.db.sql"/>
<sql:sql id="results" query="select * from urun"/>
<table border="1" align="center">
<thead>
<th>Urun NO</th>
<th>Urun Adı</th>
<th>Fiyat</th>
<th>Resim</th>
</thead>
<c:foreach var="#{$results}" item="$urun">
<tr>
<td>#{$urun.no}</td>
<td>#{$urun.ad}</td>
<td>#{$urun.fiyat}</td>
<td><img src="#{$urun.resim}"/></td>
</tr>
</c:foreach>
</table>
</faces>
</body>
</html>

FQL Etiketi
FQL etiketi query niteliğine paremetre olarak verilen FQL sorgusu işletir ve id niteliğine verilen isim ile bir sonuc kümesi getirir.

Örnek

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<faces>
<@import prefix="f" taglib="phpf.ui.*"/>
<@import prefix="fql" taglib="phpf.db.fql"/>
<fql:fql id="results" query="select u from urun u"/>
<f:grid name="grid" height="30%" width="75%" bind="$results" border="1">
<@item   key="no"  title="no" />
<@item   key="ad" title="Urun adı"/>
<@item   key="fiyat" title="fiyat"/>
</f:grid>
</faces>
</body>
</html>

SQL ve FQL etiketlerine @item etiketinin value niteliği ile parametre aktarılabilir.

Örneğin aşağıdaki gibibir ifademiz olsun

SELECT u FROM urun u WHERE u.fiyat >? AND u.fiyat <?

Örnek fiyat aralığı

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<faces>
<@import prefix="f" taglib="phpf.ui.*"/>
<@import prefix="fql" taglib="phpf.db.fql"/>
<fql:fql id="results" query="select u from urun u WHERE u.fiyat >? AND u.fiyat <?">
<@item value ="100"/>
<@item value= "500"/>
</sql:fql>
<f:grid name="grid" height="30%" width="75%" bind="$results" border="1">
<@item   key="no"  title="no" />
<@item   key="ad" title="Urun adı"/>
<@item   key="fiyat" title="fiyat"/>
</f:grid>
</faces>
</body>
</html>
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Facebook yorumları:

Yorum yaz