get_sql_clauses example


    public function get_sql( $primary_table$primary_id_column ) {
        $this->primary_table     = $primary_table;
        $this->primary_id_column = $primary_id_column;

        return $this->get_sql_clauses();
    }

    /** * Generates SQL clauses to be appended to a main query. * * Called by the public WP_Tax_Query::get_sql(), this method * is abstracted out to maintain parity with the other Query classes. * * @since 4.1.0 * * @return string[] { * Array containing JOIN and WHERE SQL clauses to append to the main query. * * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } */
        return preg_replace( '/[^a-zA-Z0-9_$\.]/', '', $column );
    }

    /** * Generates WHERE clause to be appended to a main query. * * @since 3.7.0 * * @return string MySQL WHERE clause. */
    public function get_sql() {
        $sql = $this->get_sql_clauses();

        $where = $sql['where'];

        /** * Filters the date query WHERE clause. * * @since 3.7.0 * * @param string $where WHERE clause of the date query. * @param WP_Date_Query $query The WP_Date_Query instance. */
        
return false;
        }

        $this->table_aliases = array();

        $this->meta_table     = $meta_table;
        $this->meta_id_column = sanitize_key( $type . '_id' );

        $this->primary_table     = $primary_table;
        $this->primary_id_column = $primary_id_column;

        $sql = $this->get_sql_clauses();

        /* * If any JOINs are LEFT JOINs (as in the case of NOT EXISTS), then all JOINs should * be LEFT. Otherwise posts with no metadata will be excluded from results. */
        if ( str_contains( $sql['join'], 'LEFT JOIN' ) ) {
            $sql['join'] = str_replace( 'INNER JOIN', 'LEFT JOIN', $sql['join'] );
        }

        /** * Filters the meta query's generated SQL. * * @since 3.1.0 * * @param string[] $sql Array containing the query's JOIN and WHERE clauses. * @param array $queries Array of meta queries. * @param string $type Type of meta. Possible values include but are not limited * to 'post', 'comment', 'blog', 'term', and 'user'. * @param string $primary_table Primary table. * @param string $primary_id_column Primary column ID. * @param object $context The main query object that corresponds to the type, for * example a `WP_Query`, `WP_User_Query`, or `WP_Site_Query`. */
Home | Imprint | This part of the site doesn't use cookies.