Esempio n. 1
0
    /**
     * Get the \mysqli_result requested by $this->workingQ instated by either $this->get() | $this->prep().
     *
     *
     * @param string $limit The limit to apply to the $this->workingQ.
     *
     * @return \mysqli_result
     */
    public function data($limit = '')
    {
        $sel = substr(ltrim($this->workingQ), 0, 6);
        if ($sel == 'SELECT') {
            return \DB::query($this->workingQ);
        }
        //if
        return \DB::query('
            SELECT 
            p.*,
            DATE_FORMAT(p.post_date,"' . \WP::settings('date_format') . '") AS format_date, 
            t.name,
            t.slug,
            c.name AS category,
            c.slug AS category_slug
            FROM (
                SELECT 
                p.ID AS post_id,
                p.post_date,
                p.post_content,
                p.post_excerpt,
                p.post_title,
                p.post_name,
                u.display_name,
                u.user_nicename
                FROM wp_posts AS p
                INNER JOIN wp_users AS u ON u.ID=p.post_author
                WHERE p.post_status="publish" AND p.post_type="post"
                ' . $this->workingQ . $limit . ' 

            ) AS p
            LEFT JOIN wp_term_relationships AS wptr ON wptr.object_id=p.post_id
            LEFT JOIN wp_term_taxonomy AS wptt ON wptt.term_taxonomy_id=wptr.term_taxonomy_id
            LEFT JOIN wp_terms AS t ON t.term_id=wptt.term_id
            LEFT JOIN wp_term_taxonomy AS wptt_category ON wptt_category.term_taxonomy_id=wptr.term_taxonomy_id AND wptt_category.taxonomy="category"
            LEFT JOIN wp_terms AS c ON c.term_id=wptt_category.term_id
            ORDER BY p.post_date DESC
        ');
    }