Forum

Copyright © 2014 Softobe. All rights reserved.

Whenever you need to configure a new connection with a database you have to create an SQLTouch document. This document contains all of your setting as the connection parameters, the table name, the layouts, the predefined searches and other variables we are going to see in this chapter.


In order to create a new document please consult the section Quick Start. Once you have created a new document and set the table, you can already search and browse your database. In the Edit Document panel you'll find other options as:




• Preferences


• Photo Quality

Set the quality of the picture you upload to your database. Choose a value from zero (poor quality) to 1 (best quality).




• Allow

You can allow the user to perform or not to perform some task on your document.


• Edit Quick Queries

If on, the user will be able to save the last search to a favourite search list and recall that search with a simple tap on the button. Usually you will set this option off if you want to force the user to perform only the Quick Queries you have defined, e.g. "Todays News", "My Own Sales of the Week". When you set this option to off, usually you set to off even the "Use Open Queries" option.


• Use Open Queries

If on, the user will be able to perform any search filling in the fields of the Open Queries section in the Search tab. Usually you will set this option to off only if you want to force the user to perform the Quick Queries only.




• Banners

In case you share with your clients a free public directoy like "Restaurants in the world" you would find useful to display your own banners and get money with that, exactly as you do on your web pages. SQL lets you define the URL of a banner image file to display or an XML file or PHP file returning an XML text containing the URL of the banner image file.


The banner image must be 320 x 60 pixels, 72 ppi and saved as jpg, tif, tiff, gif or png (with one of these extensions).


• Static Link

You can set an URL of a simple image on your web site jpg, tif, gif or png. For instance:


http://www.mysite.com/sqltouchdb/banners/1.jpg


In this case SQLTouch will display the banner but it will be not clickable.

You can turn your banner clickable appending the target-URL after the link, this way:


http://www.mysite.com/sqltouchdb/

banners/1.jpg?target=http://www.clientdomain.com/aproduct.html


SQLTouch will download the banner any time the SQLTouch document is open. In this case (Static Link) the link and target will be always the same. You could periodically change the file jpg on your web site and/or redirect the target link, but this is not a common practice.

If you need to rotate your banners you should use the dynamic link shown here below.




• Dynamic Link

You can provide a different banner-URL and target-URL at any time the database is open, providing the URL of any file that returns an XML text. It could be an XML file itself or a PHP script returning an XML text. For example, in case the URL regards an XML file, you'll set:


http://www.mysite.com/sqltouchdb/banners.plist


The XML document "banner.plist" must have the following contents


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>version</key>

<integer>1</integer>

<key>list</key>

<dict>

<key>clickGoToURL</key>

<string>http://www.clientdomain.com/aproduct.html</string>

<key>imageURL</key>

<string>http://www.mysite.com/sqltouchdb/banners/1.jpg</string>

</dict>

</dict>

</plist>


In case the URL regards a PHP script returning the XML text, you'll set:


http://www.mysite.com/sqltouchdb/banners.php


With a php you could even detect the calling IP country to provide different banners in different languages. In the PHP sample here below, we randomly pick the banners from a subfolder called "banners". We show you here below the content of the php file.


<?php

header('Content-Type: text/html; charset=utf-8');


$bannersFolderPath = dirname("http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']) ."/banners/";

$randNum = rand (1, 9);

$bannerPath = $bannersFolderPath . $randNum . ".jpg";


$xmlStr = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>

<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">

<plist version=\"1.0\">

<dict>

<key>version</key>

<integer>1</integer>

<key>list</key>

<dict>

<key>imageURL</key>

<string>".$bannerPath."</string>

<key>clickGoToURL</key>

<string>http://www.softobe.com/</string>

</dict>

</dict>

</plist>";


echo $xmlStr;

?>


The $bannersFolderPath variable will result in the sub-folder path


http://www.mysite.com/sqltouchdb/banners/


In this folder we put the 9 banners called 1.jpg, 2.jpg... 9.jpg.

The variable $randNum will be a random number between 1 and 9.

Therefore the $bannerPath variable will result in one of the image files, e.g.


http://www.mysite.com/sqltouchdb/banners/3.jpg


We return this path $bannerPath into the XML text, with the key imageURL. Then we return the XML text with the last echo command.

The target link http://www.sqltouch.com/ which here has the key clickGoToURL, is actually static, but it can be dynamic as well.

The version must be 1 for now. In case we add more protocols to link the banners to SQLTouch we will introduce new versions and let you know.


So, any time we open the SQLTouch document, we will get a different banner (randomly from 1.jpg to 9.jpg) and if we tap on the banner we will be taken to the sqltouch.com web site by Safari.


Download the php script, the banners folder and the sql database file.




• Actions

In this section you can perform some action.


• Reset Layouts

Pressing this button causes SQLTouch reset the layouts to the default values, as well as when you have created the document. You will lose your custom layouts. Use it only if you have done a disaster on your layouts.


• Publish to FTP

To know how to use this action please consult the Sharing section.

SQLTouch Documents

SQLTouch | Quick Start | MySQL | Documents | Layouts

Software development for OS X and iOS