Fabrik User Manual 0



Yüklə 1,97 Mb.
Pdf görüntüsü
səhifə20/24
tarix17.09.2018
ölçüsü1,97 Mb.
#69275
1   ...   16   17   18   19   20   21   22   23   24

ie. If the value is John then the prefilter expression would be
where name EQUALS 'John'
◦ Eval - fabrik expects the value to be a piece of PHP code that returns the
value to search on. So, we can make the same prefilter as in the first
example if the the type is set to eval and our value is:
return 'John';
◦ Query - Fabrik expects the value to be an SQL query that returns the
value to search on. So, we can make the same prefilter as in the first
example if the type is set to Query and our value is:
select 'John';
◦ No quotes - Use this if you want to compare numeric or date values.
• Apply filter beneath - This access control tells FAbrik to ONLY apply the pre-
filter IF the user is of the selected access level or Beneath. So setting it to
"Administrator" will mean that the filter is applied to all users EXCEPT super
administrators.
Adding an additional prefilter
When you add an additional prefilter - there are a couple of additional options that need
to be selected.
To explain these settings lets take the example of this data set:
Name
Age
Sex
John
19
Male
John
21
Male
Alice
19
Female
Rob
31
Male
and the following three prefilters:
where name EQUALS John (type text) AND age EQUALS 19 (type no quotes)AND sex
EQUALS male
The 'AND's here are set up by the drop down list that appears underneath the grouped
radio buttons.
This will return the data set:
Name
Age
Sex
John
19
Male
changing all of the ANDs for ORs would give this query:
where name EQUALS John (type text) OR age EQUALS 19 (type no quotes)OR sex
EQUALS male
90


and this data set:
Name
Age
Sex
John
19
Male
John
21
Male
Alice
19
Female
Applying grouped to the second query and reverting the second query from OR to AND
would give us:
where (name EQUALS John (type text) AND age EQUALS 19 (type no quotes)) OR sex
EQUALS male
which in turn gives the following data:
Name
Age
Sex
John
19
Male
John
21
Male
Rob
31
Male
91


Joins
When designing database tables it is always wise to think of each table as an object or
relationship, examples of objects are 'teachers', 'students', 'classes', examples of
relationships are 'which students attend which classes'.
Joins allow you to create relationships between these tables so that your Fabrik table
shows merged data from across these tables. For further reading on joins please see the
mySQL join page
When you edit a record from such a Fabrik table, Fabrik automatically knows which data
gets inserted into which database table.
To add a Join press the "Add" button at the top of the joins section, as you go about
creating your join a preview of the join query will appear at the bottom of the join
section.
• Join type - defines how the data is joined together. Please read
this excellent
article
on the difference between each of the join types
• From - The table to join from, for your first join this will always be the main
database table that your Fabrik table is using
• To - the database table name that you want to join to
• From column - the column that contains the data that needs to be matched in
the "to" table's "to column". For those of you with some database knowledge
think of this as a foreign key
• To column - the database field whose data should match the data found in the
'From' table's 'from column'.
92


Related Data
• Table - the table that contains a database join element pointing to the current
table you are editing
• Link to table - if you select 'yes' then a column will be added to your table. This
column will contain a link which will take you to the related table, filtering its
results based on the current row's primary key.
E.g:
◦ Your table is called 'teachers' and the related table is 'Students'
◦ Students has a database join element to list which teacher is that
student's mentor.
◦ Activating the 'teachers' link to table option will create a link which for
each listed teacher will show the students that the teacher mentors.
• Label - the link to table's label - e.g. 'students being mentored'
• Popup -
◦ No - the link will open in the same page
◦ Yes - the link will open in a popup window
• Link to form - creates a new column with a link to the related table's form. The
database join element will be pre-filled with the active records value.
E.g.
◦ Your table is called 'teachers' and the related table is 'Students'
◦ For the teacher 'Bob Hope' You click on the link 'add student'
◦ The students form appears and its 'mentor' database join element is pre-
filled with 'Bob Hope' as the desired mentor.
• Label - the link to form's label - e.g. 'add student'

• Popup -
◦ No - the link will open in the same page
◦ Yes - the link will open in a popup window
93


Table Filters
This applies to all Fabrik 2.0 releases after 2.0rc3
Filters can be applied to a Fabrik table via the following means:
• Querystrings
• Pre-filters
• Element filters
• The table search all filter
• Filter form
Regardless of which method is used the filters are stored in the session (which means
that their results are 'sticky' and will be applied each time the table is viewed
Filtering via the query string
The simplest way to filter in the querystring is to append
"&tablename___elmentname=value" to it
URL date filters accept times that can be converted using PHP's strtotime function
(http://php.net/strtotime)
If you want to match upcoming records for the next 2 weeks you can do this:
?tablename___time_date[value][]=now&tablename__time_date[value][]=%2B2
week&tablename___time_date[condition]=BETWEEN
note the "%2B" in the second date value is the url encoded version of '+'
If you want to match the records from last week you can do this:
?tablename___time_date[value][]=-1
week&tablename__time_date[value][]=now&tablename___time_date[condition]=BETWEEN
If you want to filter on a series of values for the same element do this:
?&tablename___elementname[value][]=64&tablename___elementname[value][]=126&tablename___elementname[value][]=127&tablename___elementname[join]=OR
The available 'conditions' are:
• BETWEEN
• BEGINS WITH
• CONTAINS
• ENDS WITH
• >
• <
• <>
94


Yüklə 1,97 Mb.

Dostları ilə paylaş:
1   ...   16   17   18   19   20   21   22   23   24




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə