Skip to content
Snippets Groups Projects
EntryQueries.php 1.02 KiB
Newer Older
  • Learn to ignore specific revisions
  • Josh Pollock's avatar
    Josh Pollock committed
    <?php
    
    
    namespace calderawp\CalderaFormsQuery;
    
    
    
    
    use calderawp\CalderaFormsQuery\Select\Entry;
    use calderawp\CalderaFormsQuery\Select\EntryValues;
    
    class EntryQueries implements QueriesEntries
    {
    	/**
    	 * SQL generator for entry table
    	 *
    	 * @var Entry
    	 */
    	protected $entryGenerator;
    
    	/**
    	 * SQL generator for entry values table
    	 *
    	 * @var EntryValues
    	 */
    	protected $entryValueGenerator;
    
    
    	/**
    	 * @var \wpdb
    	 */
    	protected $wpdb;
    
    	public function __construct( Entry $entryGenerator, EntryValues $entryValueGenerator, \wpdb $wpdb )
    	{
    		$this->entryGenerator = $entryGenerator;
    		$this->entryValueGenerator = $entryValueGenerator;
    		$this->wpdb = $wpdb;
    	}
    
    	/** @inheritdoc */
    	public function getResults( $sql )
    	{
    		$results = $this->wpdb->get_results( $sql );
    		if( empty( $results ) ){
    			return [];
    		}
    		return $results;
    	}
    
    	/** @inheritdoc */
    	public function getEntryValueGenerator()
    	{
    		return $this->entryValueGenerator;
    	}
    
    	/** @inheritdoc */
    	public function getEntryGenerator()
    	{
    		return $this->entryGenerator;
    	}
    
    }