dataface url protocols steve hannah web lite solutions corp. [email protected] steve hannah web lite...

17
Dataface URL Protocols Steve Hannah Web Lite Solutions Corp. [email protected]

Upload: beryl-fowler

Post on 14-Dec-2015

224 views

Category:

Documents


3 download

TRANSCRIPT

Dataface URL ProtocolsDataface URL Protocols

Steve Hannah

Web Lite Solutions Corp.

[email protected]

Steve Hannah

Web Lite Solutions Corp.

[email protected]

Anatomy of a URLAnatomy of a URL

URLs allow you to pass parameters to PHP scripts via GET variableseg: http://yourdomain.com/index.php?name=foo

The above would pass the parameter “name” with value “foo” to the index.php script.

The question mark (‘?’) in a URL indicates that everything that follows are parameters.

Multiple parameters can be separated by an ampersand (‘&’):http://yourdomain.com/index.php?name=foo&size=10

URLs allow you to pass parameters to PHP scripts via GET variableseg: http://yourdomain.com/index.php?name=foo

The above would pass the parameter “name” with value “foo” to the index.php script.

The question mark (‘?’) in a URL indicates that everything that follows are parameters.

Multiple parameters can be separated by an ampersand (‘&’):http://yourdomain.com/index.php?name=foo&size=10

Dataface URL InstructionsDataface URL Instructions

Parameters beginning with ‘-’ are instructions for Dataface:e.g. -action=list or -table=peopleTo tell dataface to perform the ‘list’ action or to show the ‘people’ table.

Instructions are maintained between multiple requests. E.g. If you are in the ‘people’ table, all links in Dataface will include ‘-table=people’ so that the user will still be in the ‘people’ table when he clicks on one of the links.

Parameters beginning with ‘-’ are instructions for Dataface:e.g. -action=list or -table=peopleTo tell dataface to perform the ‘list’ action or to show the ‘people’ table.

Instructions are maintained between multiple requests. E.g. If you are in the ‘people’ table, all links in Dataface will include ‘-table=people’ so that the user will still be in the ‘people’ table when he clicks on one of the links.

Dataface URL MetadataDataface URL Metadata

GET parameters beginning with ‘--’ are metadata for the current request.E.g. --msg=Records%20Successfully%20DeletedPasses a message parameter to display in the Info dialog.

Metadata is not passed between requests. They are for one request only.

This convention is useful for custom actions when you want to pass special information to your action that shouldn’t persist across requests.

Why not just pass your parameters normally (without the prepended ‘--’? Answer: Next slide

GET parameters beginning with ‘--’ are metadata for the current request.E.g. --msg=Records%20Successfully%20DeletedPasses a message parameter to display in the Info dialog.

Metadata is not passed between requests. They are for one request only.

This convention is useful for custom actions when you want to pass special information to your action that shouldn’t persist across requests.

Why not just pass your parameters normally (without the prepended ‘--’? Answer: Next slide

Query ParametersQuery Parameters

GET parameters not beginning with ‘-’ are considered to be search parameters.

LastName=Smith will filter the results to only show records where the LastName field contains the phrase ‘Smith’. This would match such names as ‘Smith’, ‘Smithy’, ‘Brownsmith’, etc…

If you need to pass parameters to your script that are NOT query parameters, you should prepend ‘-’ or ‘--’ to the parameter name so Dataface doesn’t confuse them for query parameters.

GET parameters not beginning with ‘-’ are considered to be search parameters.

LastName=Smith will filter the results to only show records where the LastName field contains the phrase ‘Smith’. This would match such names as ‘Smith’, ‘Smithy’, ‘Brownsmith’, etc…

If you need to pass parameters to your script that are NOT query parameters, you should prepend ‘-’ or ‘--’ to the parameter name so Dataface doesn’t confuse them for query parameters.

Query Parameter Fun IQuery Parameter Fun I

FirstName=BobMatches ‘Bob’, ‘bob’, ‘Bobby’, ‘cabob’, …

FirstName==BobMatches ‘Bob’, ‘bob’, but not ‘Bobby’ or ‘cabob’

FirstName=>BobMatches ‘Bobby’, ‘Carl’, ‘Doug’, but not ‘Adam’, ‘Ark’, ‘Bill’, or ‘Bob’. (I.e. matches any name coming after ‘Bob’ in the lexicographic alphabetical ordering).

FirstName=BobMatches ‘Bob’, ‘bob’, ‘Bobby’, ‘cabob’, …

FirstName==BobMatches ‘Bob’, ‘bob’, but not ‘Bobby’ or ‘cabob’

FirstName=>BobMatches ‘Bobby’, ‘Carl’, ‘Doug’, but not ‘Adam’, ‘Ark’, ‘Bill’, or ‘Bob’. (I.e. matches any name coming after ‘Bob’ in the lexicographic alphabetical ordering).

Combining Parameters: ANDCombining Parameters: AND

Putting multiple search parameters together is equivalent to performing an ‘AND’ on the parameters.

E.g. FirstName=Bob&LastName=Smithwould match records with FirstName ‘Bob’ and LastName ‘Smith’. But ‘Bob McKenzie’ would NOT be matched.

Putting multiple search parameters together is equivalent to performing an ‘AND’ on the parameters.

E.g. FirstName=Bob&LastName=Smithwould match records with FirstName ‘Bob’ and LastName ‘Smith’. But ‘Bob McKenzie’ would NOT be matched.

Exercise IExercise I

Bringing it togetherBringing it together

Index.php?-action=list&-table=People&FirstName=Bob

Will show the list view for the People table. Showing only results where FirstName contains ‘Bob’ (case insensitive).

Index.php?-action=edit&-table=People&UserID=10Will show the edit form to edit the record from the People table with UserID=10.

Index.php?-action=view&-table=People&UserID=10&--msg=Welcome+to+my+site

Will show the view tab for the record from the People table with UserID=10. Will display an info message saying “Welcome to my site” along to top.

Index.php?-action=list&-table=People&FirstName=Bob

Will show the list view for the People table. Showing only results where FirstName contains ‘Bob’ (case insensitive).

Index.php?-action=edit&-table=People&UserID=10Will show the edit form to edit the record from the People table with UserID=10.

Index.php?-action=view&-table=People&UserID=10&--msg=Welcome+to+my+site

Will show the view tab for the record from the People table with UserID=10. Will display an info message saying “Welcome to my site” along to top.

Full-text SearchingFull-text Searching

Use the -search instruction to perform full-text search on all columns

-search=Bob+SmithMatches records containing both ‘Bob’ and ‘Smith’. Matches can occur on any text or varchar column in the record.

Use the -search instruction to perform full-text search on all columns

-search=Bob+SmithMatches records containing both ‘Bob’ and ‘Smith’. Matches can occur on any text or varchar column in the record.

Combining Parameters: ORCombining Parameters: OR

FirstName=Bob+OR+CarlMatches ‘Bob’, ‘Bobby’, ‘cabob’, ‘Carl’, ‘Carly’, ‘my carly’.

Currently no way to perform OR query over multiple columns. E.g. Cannot match records with FirstName Bob OR LastName Smith.

FirstName=Bob+OR+CarlMatches ‘Bob’, ‘Bobby’, ‘cabob’, ‘Carl’, ‘Carly’, ‘my carly’.

Currently no way to perform OR query over multiple columns. E.g. Cannot match records with FirstName Bob OR LastName Smith.

Query Parameter Fun IIQuery Parameter Fun II

FirstName=<BobMatches ‘Adam’, ‘Bill’ but not ‘Bob’, ‘Carl’, ‘Derek’, etc… (I.e. matches names before ‘Bob’ in lexicographic alphabetical ordering).

FirstName=Bob..CarlMatches ‘Bob’, ‘Carl’, ‘Buster’, ‘Cam’, but not ‘Adam’ or ‘Carly’ (I.e. Matches names between ‘Bob’ and ‘Carl’ inclusive).

FirstName=<BobMatches ‘Adam’, ‘Bill’ but not ‘Bob’, ‘Carl’, ‘Derek’, etc… (I.e. matches names before ‘Bob’ in lexicographic alphabetical ordering).

FirstName=Bob..CarlMatches ‘Bob’, ‘Carl’, ‘Buster’, ‘Cam’, but not ‘Adam’ or ‘Carly’ (I.e. Matches names between ‘Bob’ and ‘Carl’ inclusive).

Actions: the -action parameterActions: the -action parameter

The -action parameter used to specify the action to perform.

Common Dataface actions:new : New record formedit : Edit an existing recordview : View tablist : The list viewfind: The find tabdelete: Deletes the current recordrelated_records_list : Show the related records (requires -relationship parameter to be the name of the relationship to show).

The -action parameter used to specify the action to perform.

Common Dataface actions:new : New record formedit : Edit an existing recordview : View tablist : The list viewfind: The find tabdelete: Deletes the current recordrelated_records_list : Show the related records (requires -relationship parameter to be the name of the relationship to show).

Exercise IExercise I

Form URLs to perform the following queries: Create a new record in the ‘People’ table. Edit record with UserID 10 in the ‘People’ table. Show enrolled courses for the Person with

FirstName ‘Grant’ and LastName ‘Drummond’ in the People table. Enrolled courses are represented by the relationship ‘courses’.

Show the edit form for the 12th record in the result set formed when searching for Country=Canada on the People table.

Form URLs to perform the following queries: Create a new record in the ‘People’ table. Edit record with UserID 10 in the ‘People’ table. Show enrolled courses for the Person with

FirstName ‘Grant’ and LastName ‘Drummond’ in the People table. Enrolled courses are represented by the relationship ‘courses’.

Show the edit form for the 12th record in the result set formed when searching for Country=Canada on the People table.

Accessing URL Parameters from PHP

Accessing URL Parameters from PHP

Steve Hannah

Web Lite Solutions Corp.

[email protected]

Steve Hannah

Web Lite Solutions Corp.

[email protected]

Accessing Parameters DirectlyAccessing Parameters Directly

Index.php?FirstName=Bob&-table=People$_GET[‘FirstName’] // ‘Bob’$_GET[‘-table’] // ‘People’

This method is OK, but doesn’t take into account default parameters. (e.g. If user requests index.php with no parameters, then Dataface implies default values for -table, -action, etc… that won’t be accessible via $_GET array).

Index.php?FirstName=Bob&-table=People$_GET[‘FirstName’] // ‘Bob’$_GET[‘-table’] // ‘People’

This method is OK, but doesn’t take into account default parameters. (e.g. If user requests index.php with no parameters, then Dataface implies default values for -table, -action, etc… that won’t be accessible via $_GET array).

Accessing Parameters from Application Object

Accessing Parameters from Application Object

$app =& Dataface_Application::getInstance();

$query =& $app->getQuery();

// Returns associative array of query parameters with default values filled in.

e.g. $query[‘-table’], $query[‘-action’], $query[‘-limit’], $query[‘-cursor’].

$app =& Dataface_Application::getInstance();

$query =& $app->getQuery();

// Returns associative array of query parameters with default values filled in.

e.g. $query[‘-table’], $query[‘-action’], $query[‘-limit’], $query[‘-cursor’].