PHP code example of calderawp / caldera-forms-query

1. Go to this page and download the library: Download calderawp/caldera-forms-query library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

calderawp / caldera-forms-query example snippets


/**
 * Examples of simple queries
 *
 * Using the class: \calderawp\CalderaFormsQuery\Features\FeatureContainer
 * Via the static accessor function: calderawp\CalderaFormsQueries\CalderaFormsQueries()
 */

/** First make the function usable without a full namespace */
use function calderawp\CalderaFormsQueries\CalderaFormsQueries;

/** Do Some Queries */
//Select all data by user ID
$entries = CalderaFormsQueries()->selectByUserId(42);

//Select all entries that have a field whose slug is "email" and the value of that field's value is "[email protected]"
$entries = CalderaFormsQueries()->selectByFieldValue( 'email', '[email protected]' );

//Select all entries that do not have field whose slug is "size" and the value of that field's value is "big"
$entries = CalderaFormsQueries()->selectByFieldValue( 'size', 'big', false );

//Delete all data by Entry ID
CalderaFormsQueries()->deleteByEntryIds([1,1,2,3,5,8,42]);

//Delete all data by User ID
CalderaFormsQueries()->deleteByUserId(42);

/**
 * Examples of simple queries
 *
 * Using the class: \calderawp\CalderaFormsQuery\Features\FeatureContainer
 * Via the static accessor function: calderawp\CalderaFormsQueries\CalderaFormsQueries()
 */

/** First make the function usable without a full namespace */
use function calderawp\CalderaFormsQueries\CalderaFormsQueries;

/** Do Some Queries */
//Select all entries that have a field whose slug is "email" and the value of that field's value is "[email protected]"
//The first 25 entries
$entries = CalderaFormsQueries()->selectByFieldValue( 'email', '[email protected]' );
//The second 25 entries
$entries = CalderaFormsQueries()->selectByFieldValue( 'email', '[email protected]', true, 2 );
//Get 5th page, with 50 results per page
$entries = CalderaFormsQueries()->selectByFieldValue( 'email', '[email protected]', true, 5, 50 );

 $featureContainer = \calderawp\CalderaFormsQueries\CalderaFormsQueries();
    $fieldValue = '[email protected]';
    $formId = 'CF5afb00e97d698';
    $count = Caldera_Forms_Entry_Bulk::count($formId );

    $entrySelector = $featureContainer
        ->getQueries()
        ->entrySelect();

    $featureContainer = \calderawp\CalderaFormsQueries\CalderaFormsQueries();
    $entrySelector = $featureContainer
        ->getQueries()
        ->entrySelect()
        ->is( 'primary_email', '[email protected]' )
        ->is( 'first_name', 'Mike' )
        ->addPagination(2,50 );

    $featureContainer = \calderawp\CalderaFormsQueries\CalderaFormsQueries();
    $entrySelector = $featureContainer
        ->getQueries()
        ->entrySelect()
        ->in( 'entry_id', [ 42, 3 ] );

        $featureContainer = \calderawp\CalderaFormsQueries\CalderaFormsQueries();
        $entryValueSelect = $featureContainer
            ->getQueries()
            ->entryValuesSelect()
            ->is( 'size', 'large' );

       $featureContainer->getQueries()->select( $entryValueSelect );


  $featureContainer = \calderawp\CalderaFormsQueries\CalderaFormsQueries();
        $sql = $featureContainer
            ->getQueries()
            ->entryValuesSelect()
            ->is( 'size', 'large' )
            ->getPreparedSql();