Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
caldera-forms-query
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plugins
cf-dependencies
caldera-forms-query
Commits
da272f8c
Commit
da272f8c
authored
May 19, 2018
by
Josh Pollock
Browse files
Options
Downloads
Plain Diff
merge conflict
parents
27edae54
527d79ed
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-5
1 addition, 5 deletions
README.md
src/Features/FeatureContainer.php
+297
-244
297 additions, 244 deletions
src/Features/FeatureContainer.php
with
298 additions
and
249 deletions
README.md
+
1
−
5
View file @
da272f8c
...
...
@@ -50,7 +50,6 @@ CalderaFormsQueries()->deleteByEntryIds([1,1,2,3,5,8,42]);
CalderaFormsQueries
()
->
deleteByUserId
(
42
);
```
### Paginated Queries
The selectByFieldValue feature method defaults to limiting queries to 25. You can set the page and limit with the 4th & 5th arguments.
```
php
...
...
@@ -72,12 +71,9 @@ $entries = CalderaFormsQueries()->selectByFieldValue( 'email', 'delete@please.eu
$entries
=
CalderaFormsQueries
()
->
selectByFieldValue
(
'email'
,
'delete@please.eu'
,
true
,
2
);
//Get 5th page, with 50 results per page
$entries
=
CalderaFormsQueries
()
->
selectByFieldValue
(
'email'
,
'delete@please.eu'
,
true
,
5
,
50
);
```
## Development
### Install
Requires git and Composer
...
...
This diff is collapsed.
Click to expand it.
src/Features/FeatureContainer.php
+
297
−
244
View file @
da272f8c
...
...
@@ -132,6 +132,7 @@ class FeatureContainer extends Container
return
$this
->
collectResults
(
$this
->
select
(
$query
));
}
<<<<<<<
HEAD
/**
* Find all entries that have or do not have field with a slug and value
*
...
...
@@ -162,6 +163,54 @@ class FeatureContainer extends Container
->
entrySelect
()
->
addPagination
(
$page
,
$limit
)
->
queryByEntryIds
(
$results
);
=======
/**
* Select entries by form ID
*
* @param string $formId ID of form to select
*
* @param bool $addValues Optional Add entry values? Default is true.
* @return array
*/
public
function
selectByFormId
(
$formId
,
$addValues
=
true
)
{
$query
=
$this
->
getQueries
()
->
entrySelect
()
->
queryByFormsId
(
$formId
);
return
$this
->
collectResults
(
$this
->
select
(
$query
),
$addValues
);
}
>>>>>>>
527
d79ed169861a0db38e730e1ed8f374b533d04
/**
* Find all entries that have or do not have field with a slug and value
*
* @param string $fieldSlug Field slug
* @param string $fieldValue Field value
* @param bool $have Optional. Default: true. If true query is for fields with this value
*
* @return array
*/
public
function
selectByFieldValue
(
$fieldSlug
,
$fieldValue
,
$have
=
true
)
{
$type
=
$have
?
'equals'
:
'notEquals'
;
$queryForEntryValues
=
$this
->
getQueries
()
->
entryValuesSelect
()
->
queryByFieldValue
(
$fieldSlug
,
$fieldValue
,
$type
,
'AND'
,
[
'entry_id'
]);
$results
=
$this
->
select
(
$queryForEntryValues
);
if
(
empty
(
$results
)
||
0
>=
count
(
$results
))
{
return
[];
}
$results
=
$this
->
reduceResultsToEntryId
(
$results
);
$queryForValues
=
$this
->
getQueries
()
->
entrySelect
()
->
queryByEntryIds
(
$results
);
return
$this
->
collectResults
(
$this
->
select
(
$queryForValues
));
}
...
...
@@ -239,9 +288,10 @@ class FeatureContainer extends Container
* Collect results using Caldera_Forms_Entry_Entry and Caldera_Forms_Entry_Field to represent values
*
* @param \stdClass[] $entriesValues
* @param bool $addValues Optional Add entry values? Default is true.
* @return array
*/
private
function
collectResults
(
$entriesValues
)
private
function
collectResults
(
$entriesValues
,
$addValues
=
true
)
{
$results
=
[];
foreach
(
$entriesValues
as
$entry
)
{
...
...
@@ -250,9 +300,12 @@ class FeatureContainer extends Container
->
getQueries
()
->
entryValuesSelect
()
->
queryByEntryId
(
$entry
->
id
);
$entriesValues
=
$this
->
select
(
$query
);
$entryValuesPrepared
=
[];
if
(
$addValues
)
{
$entriesValues
=
$this
->
select
(
$query
);
$entryValuesPrepared
=
$this
->
collectEntryValues
(
$entriesValues
);
}
$results
[]
=
[
'entry'
=>
$entry
,
'values'
=>
$entryValuesPrepared
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment