Introduction

Account

Web System Common Tools

Web System Applications Development

 Web System Database Web System PostgreSQL Tables Web System Manage fields Web System Manage constraints Web System Manage indexes Web System Manage triggers Web System SQL Tab Web System Single-row editing Web System Multirow editing in table mode Web System Import Web System Export Web System Table transfer - or Store Web System Composite Types Web System SQL Queries Web System Workflow Web System Dataset Design Web System Query Expressions Web System Where Conditions Web System Group by Expressions Web System Having Condition Web System Windows Clause Web System Order by Expressions Web System SQL Tab Web System Test a Query Web System Views Web System Functions Web System Datasources Web System Charts Web System Main type selection Web System Subtype selection Web System Datasource selection Web System General settings Web System Axis settings Web System Background settings Web System Margin settings Web System Color settings Web System Mark settings Web System QR Barcodes Web System Saving Web System Reports Web System Template Editor GYRE Web System Sections Web System Toolbar Web System Basic properties Web System Data formatting Web System Text Web System Data Web System Macro Web System Geometry Web System Line Web System Bezier curve Web System Image Web System Chart Web System Arrangement Web System Clipboard Web System History Web System Zoom Web System Import/export Web System Delete Web System Report Generator Web System Report Schedule Web Site Builder Web System Content Management System (CMS) Web System Edit site Web System Themes and pages Web System Create and edit theme Web System Edit page Web System Web Form Builder / Content Editor (GYRE) Web System Toolbar Web System Events Web System Basic properties Web System Text field Web System Button Web System List Web System Combobox Web System Label Web System Checkbox Web System Radiobutton Web System Filler Web System Upload file Web System Additional tools (Gears) Web System Image Web System Flash video Web System Arrangement Web System Clipboard Web System History Web System Zoom Web System Import/export Web System Delete Web System Operations with objects Web System DNS Manager Web System SEO tools Web System App Analyzer Web System Reindex Web System Publish Web System Access Log Web System Checkout settings Web System PHP Scripts development (Actions) Web System Source Editor Web System API functions Web System Custom Scripts development (JS, CSS, XML, etc...) Web System Gears Web System SaaS Solution Manager

Web System Cook book

Web System Deprecated

Web System Datasources

For this discussion - lower case 'datasource' is different from 'Datasource', which is treated as a special type of Object in the Younicycle system. A Datasource is a datasource, with four additional (4) Php Actions (statements) which are automatically created and correctly pointed.  These statements can also be edited to further manipulate the data.

An Object Datasource is used to exchange information between the tables, queries, or external XML-Resources, and visual components and data management. In general, all objects - Tables, Queries, Views - are datasources. If there is no need for additional data processing before output, it is preferable to directly use those objects in the GYRE editor. The specific object - Datasource - is useful when there is a need to analyze or process the data before output, or receive data from an external XML resource.

Below are two drawings reflecting the flow of data using Datasource.

Datasource diagram (1)

Drawing 1.

Datasource diagram (2)

Drawing 2.

To create a datasource, select Datasources from Y-Tree menu and then click on New Datasource or click the icon Datasource Builder from your internal Home page.  When you create a datasource, you must specify its name, description (optional), pick a source from which the data will be selected and specify the limit on the number of records (default 0 - no limit), and a folder.

Creating a Datasource

A Table, or a Query, as well as an external XML-resource serve as data sources for a Datasource object. When sourcing data from tables or queries, one must also choose the name of the object from which the sample will be selected. If an external XML-resource is used as a source no additional selection steps are necessary.

After filling out all mandatory fields, click Create, creating a Datasource object.


When a Datasource is created, four additional Statements are also created - Select, Update, Insert, Delete. Each Statement is an Action type object (see (ref: 77)), allowing you to perform data manipulation of the Datasource.

  • Select – occurs when data is selected from a Datasource
  • Update – occurs when editing data in a Datasource
  • Insert – occurs when records are added to a Ddatasource.
  • Delete – occurs when records are deleted from a Datasource.

The Statements are accessed through Edit  properties/statements.

Editing Datasource

Editing a Select Statement

An example of a Select Statement for a table based datasource:

$records = $yc->getRecordsFromTable('products');

return $records;

In this example, there is no additional data editing, only selection from a table. In this case,  a Datasource object may be uneccessary as it is usually preferable to use tables directly. Datasource type objects are a little more resource-intensive and slower.

An example of Select Statement for a Datasource sampled from an external XML resource:

$result = array();
$xml_file = "http://weather.yahooapis.com/forecastrss?p=10002&u=F";
$xml = simplexml_load_file($xml_file);
foreach($xml->channel as $channel)
{
  $row = array();
  $row['Title']['value'] = (string)$channel->title;
  $row['Weather']['value'] = (string)$channel->item->description;
  $row['__id__']['value'] = 1;
  $row['__author__']['value'] = 'weather.yahooapis.com';
  $row['__date__']['value'] = date('Y-m-d H:i:s');
  $result[] = $row;
}
return $result;

The example above is a sample of weather data for the city of New York (10002) from Yahoo Weather.  This would be a good use for a Datasource Object - as the Statement is required in order to pull only the desired data from a much larger set of data.

Attention! Fields "__id__", "__author__", "__date__" may be empty, but must be present in the result dataset. These fields are not displayed when viewing the datasource because they are systemic.

When done, the Datasource can be loaded to an Application, Template, Web Site Theme or Website Page via the GYRE in the Properties Palette.