I’ve just started using WP Data Access Premium in earnest and now migrating my existing internal reporting dashboard (written in .NET) to WP using your great plug-in – mainly to speed up ongoing development. However, I’m finding it tricky to implement (what seems to me a simple) particular requirement:
I have the following query which will just simply aggregate values between a date range from a view – like this:
SELECT
retailer_id, vendor_code, company_name,
SUM(num_sales) AS total_trans_count,
SUM(revenue) AS total_revenue
FROM vrpt_rev_daily_by_retailer_v1
WHERE trans_date BETWEEN <<DATE 1>> AND <<DATE 2>>
GROUP BY retailer_id
So effectively it’s summing a column for rows between a given range, for each retailer.
What I effectively want to do on the DATA PUBLISHER is just have a flat table with two dynamic filters (From Date and To Date) – which are used as the aggregate params and that’s it.
In my existing system, I just pass in the two date values and it builds the SQL (as above) and fires it off – but I’m struggling to see how this can be achieved using WP Data Access. Date ranges are a common theme in reporting systems – so some pointers would be great to achieve this. In summary:
1) Can you specify aggregate fields (e.g. SUM() ) ?
2) Can two filter values be passed back in as a BETWEEN clause ?
Or do I need to drop into code to do this – which is what I’m trying to avoid by using this tool?
Cheers
Matt
]]>I’ve made a calendar system where each month has his own page. If the page name equals the current month, the month page doesn’t need a header and footer.
I’ve already made that codes, but I am searching for the if-clause ‘if page name is current month’.
Is there a way to use date('m')
to check if the month page is the current month?
This is the if-clause: (the 'July 2015'
has to change automatically)
<?php if (is_page('July 2015')) : ?>
MONTH PAGE WITHOUT HEADER AND FOOTER
<?php else : ?>
FULL MONTH PAGE
<?php endif; ?>
Thanks a lot!
It should also be noted that I have added a custom meta field to the Pages editor. This meta field pulls the ‘calltoaction’ taxonomy list and displays it as a group of checkbox options. This will allow the person editing the page to select which ‘Calls to Action’ are allowed to be shown on the given page.
What I would like to happen:
What is actually happening:
Up to this point, all my code and customizations work correctly. I am able to get a single, random ‘Call to Action’ to show. However, when I try to pass the array of allowed ‘Calls to Actin’ to the query it’s not working.
Here’s the code that works:
$args=array('post_type'=>'calltoaction', 'orderby'=>'rand', 'posts_per_page'=>'1');
$calltoaction = new WP_Query($args);
Here’s the code I would like to get working:
$supported_cta = get_post_meta(get_the_ID(), 'supported_cta', true);
$where = array(
'key' => 'cta_category',
'value' => $supported_cta,
'compare' => 'IN'
);
$args=array('post_type'=>'calltoaction', 'orderby'=>'rand', 'posts_per_page'=>'1', 'meta_query'=>$where);
$calltoaction = new WP_Query($args);
Please let me know if you need more information or if screenshots of the custom post and taxonomy would help.
]]>I have the following code in my page.php.
It currently loops through a set of posts, however I want to change the order. How do I do this?
[Code moderated as per the Forum Rules. Please use the pastebin]
Many thanks!
]]>I want to display a “contact me” button at the bottom of each page but on the contact page itself. What would be the code to do that?
Here is the page where I don’t want the display button to show: Modchip Montreal
Thanks
]]>WordPress database error: [Unknown column ‘cat_’ in ‘order clause’]
SELECT * FROM wp_categories WHERE cat_ID > 0 AND link_count > 0 ORDER BY cat_ ASC
Any ideas?
]]>So… I checked my PHP and SQL versions:
PHP 4.4.1
MySQL 4.0.16
I backed up my blog (thank God!).
I changed the files over.
I ran the update.php. It didn’t work. I got an “Unknown column ‘post_type’ in ‘where clause'”
In fact, I got one of these on nearly every element of the blog — the header, the sidebar items, the footer too if I recall correctly. Update.php just wasn’t gonna run.
I restored everything from backup.
On coming back, Akismet is broken, which is a pain because I can’t get a version of Akismet that works with WP 1.5.1.3 anymore.
So all I’ve gotten for my efforts were several wasted hours and now tons and tons of spam.
Can anyone help? With any of these concerns? I’d really appreciate it, and I’d sing your praises from my blog.
]]>What does it mean and what do I need to do to correct this, it was from a fantastico upgrade/update by my web host… left side bar shows archives but none of the personal links / categories headers I added show – everything else seems to be fine so far…
if you need to see it, the URL is: my user name.biz/blog/
thanks in advance