Location: PHPKode > projects > XMLNuke Web Development Framework XML > xmlnuke-php5-v3.5r356/xmlnuke-php5/data/sites/docs/xml/en-us/technicalref_3.en-us.xml
<?xml version="1.0" encoding="utf-8"?>
<page>
	<meta>
		<title>Data Repository - AnyDataSet</title>
		<abstract>Data Repository - AnyDataSet</abstract>
		<created>20/9/2005 00:29:04</created>
		<modified>Wed Nov 19 2008 14:57:02</modified>
		<keyword>xmlnuke</keyword>
		<groupkeyword>technicalref</groupkeyword>
		<revision>$Revision: 1.1 $</revision>
	</meta>
	<code information="PHP"><![CDATA[

]]></code>
	<blockcenter>
		<title>Data Repository - AnyDataSet</title>
		<body>
			<p>
XMLNuke has several ways to store and recover information from a data repository, whether through a local database (for small amounts of data) or in a relational database like MySQL or Oracle.
         </p>
			<p>
It's important to understand that regardless of the method used to access the data, the manipulation method is practically the same (for queries).
         </p>
			<p>
AnyDataSet is very flexible because it does not have a predefined database structure, so that each line may contain distinct entries. In any case, it's recommended that you use it for small entries only.
         </p>
		</body>
	</blockcenter>
	<blockcenter>
		<title>Reading an AnyDataSet</title>
		<body>
			<p>
				<code information="CSharp"><![CDATA[
AnydatasetFilenameProcessor guestbookFile = 
new AnydatasetFilenameProcessor("guestbook", this._context);
AnyDataSet guestbook = new anydataset.AnyDataSet(guestbookFile);
Iterator it = guestbook.getIterator();
while (it.hasNext())
{
	SingleRow sr = it.moveNext();
	//sr.getField("campo");
}
]]></code>
			</p>
			<p>
				<code information="PHP"><![CDATA[
// require_once("bin/com.xmlnuke/module.basemodule.class.php");
$guestbookFile = new AnydatasetFilenameProcessor("guestbook", $this->_context);
$guestbook = new AnyDataSet($guestbookFile);
$it = $guestbook->getIterator();
while ($it->hasNext())
{
	$sr = $it->moveNext();
	//$sr->getField("campo");
}
]]></code>
			</p>
		</body>
	</blockcenter>
	<blockcenter>
		<title>Filtering the data of an AnyDataSet</title>
		<body>
			<p>
When obtaining the data from an AnyDataSet with the getIterator() method, you can send an IteratorFilter.
</p>
			<p>
				<code information="CSharp"><![CDATA[
IteratorFilter itf = new IteratorFilter();
itf.addRelation("destination_id", Relation.Equal, "valor");
Iterator it = guestbook.getIterator(itf);
]]></code>
			</p>
			<p>
				<code information="PHP"><![CDATA[
$itf = new IteratorFilter();
$itf->addRelation("destination_id", Relation::Equal, $destination_id);
$it = $configEmail->getIterator($itf);
]]></code>
			</p>
		</body>
	</blockcenter>
	<blockcenter>
		<title>Inserting data to an AnyDataSet</title>
		<body>
			<p>
The process for inserting data to an AnyDataSet is very simple.
         </p>
			<p>
				<code information="CSharp"><![CDATA[
anydata.appendRow();
anydata.addField("fromname", "nome");
anydata.addField("frommail", "email");
anydata.addField("ip", this._context.ContextValue("REMOTE_ADDR"));
anydata.Save(guestbookFile);
]]></code>
			</p>
			<p>
				<code information="PHP"><![CDATA[
$anydata->appendRow();
$anydata->addField("fromname", "nome");
$anydata->addField("frommail", "email");
$anydata->addField("ip", $this->_context->ContextValue("REMOTE_ADDR"));
$anydata->Save(guestbookFile);
]]></code>
			</p>
		</body>
	</blockcenter>
</page>
Return current item: XMLNuke Web Development Framework XML