Tuesday, 7 August 2012

Mysql - Can I use WHERE and HAVING in the same query

Yes is the quick answer .  It's just about the order that you call the 'HAVING' or 'WHERE' up. 

Have a look at this webpage  How to call up HAVING and WHERE in the same MYSQL query  

So with the following statement

select id, user_id, cdate, start_time, end_time, count(*)
  from vfvi7_pf_time_tracking
  group by user_id, cdate
  having count(*) >1



I cannot put my WHERE clause at the end but need to put it before the GROUP BY; like this


select id, user_id, cdate, start_time, end_time, count(*)
  from vfvi7_pf_time_tracking
  WHERE dShftChked !=1
  group by user_id, cdate
  having count(*) >1



Friday, 3 August 2012

Mysql - Grouping Row and Counting them

The problem:  I am printing out shifts done at certain venues.  And what I want to do is on some shifts rather than print out every shift; if the shift is done at the same time on the same date then these can be grouped together .  Also though I'll need to know how many shifts have been grouped together to refer to later in my code.

Question : can I group by 3 different columns.

Yes. and this gives me less row results - so if I can get a count of how many rows have been grouped then I'm on to a winner.

Question:  How Can i get a count of how many rows have been grouped together by GROUP BY in MySQL

By using count(*) as count in the select .  this gives me a column with how many times some rows have been grouped

Here's the original mysql call .


SELECT * FROM vfvi7_pf_time_tracking
WHERE vfvi7_pf_time_tracking.cdate >=1339974000
AND vfvi7_pf_time_tracking.cdate <=1340578800
AND vfvi7_pf_time_tracking.project_id =7


and the new mysql call is

SELECT *, count(*) as count
FROM vfvi7_pf_time_tracking
WHERE vfvi7_pf_time_tracking.cdate >=1339974000
AND vfvi7_pf_time_tracking.cdate <=1340578800
AND vfvi7_pf_time_tracking.project_id =7  GROUP BY vfvi7_pf_time_tracking.cdate, vfvi7_pf_time_tracking.start_time, vfvi7_pf_time_tracking.end_time

Thursday, 2 August 2012

Joomla Frontpage Slideshow - Ordering Problem

Being able to get your slides in order isn't as straight forward as it seems for the Joomla component Frontpage Slideshow;  So yesterday I made a short video for a client explaining how to do this.

joomla development how to make a menu item for your component

 Here's a real quick one.  I'd made a component and couldn't find it in the menu selection in administrator. 

To make sure your component is added to the menu selections then follow the instructions here.
 
Joomla Development - Add a Component Menu Item

My mistake was really simple though and that was that I was already using the same title  !!


Friday, 27 July 2012

virtuemart 2.0 Paypal payment method not working

After setting up my Virtuemart 2.0 store ; and setting up a payment method of Paypal - it wasn't working.


The solution was to fill in all the min max details ( i also changed the group to 'default' ) and it now works.


Thursday, 19 July 2012

Adding PAYE and NON-PAYE ordering and message to the Bacs report.

This is working in the Joomla Payroll System component I am developing.   I have already added a tick box to the employee area and now I need to add conditions to the BACS report so firstly the ordering is done by the Pay Type.  and then secondly I need to pick up when the change over happens in the table that is out putted.

The details actually pass in and out of two tables when calculated.

OPEN components/com_projectfork/models/bacs.php

in the Query on line 50 that gets the details from the shifts - get the info from the column #__comprofiler.cb_PayType that had been added.

on line 88 that information is picked up again with

$PayType=$hrs->cb_PayType;


and passed into the #__time_diff  row.  Which I've again set up the respective column.


line 107  - information retrieved from #__time_diff . This time as well as filling the array with  the #__time_diff.PayType column; we also use the column to ORDER BY .  So that all the nonPAYE comes first and PAYE second.

ORDER BY #__time_diff.PayType



on line 151 we add the details to yet another table in

, '$datares->PayType'



It's from this table that's called up in the page

OPEN components/com_projectfork/views/bacs/tmpl/default.php


on line 82 the following code deals with whether or not to tell the frontend that the PAYE & NON PAYE columns have started.

$PAYEorNOT = $ids->PayType;



if ($lastPAYE != $PAYEorNOT ){

echo ' ';


if($PAYEorNOT == '0'){

echo 'NON PAYE';
}


elseif($PAYEorNOT == 1 )
{

echo 'PAYE';


}


echo '';


$lastPAYE = $PAYEorNOT;

}

FOR THIS TO WORK YOU ALSO NEED THE TABLE CELLS


#__time_diff.PayType
#__comprofiler.cb_PayType
#__ alterations_bacs_amount.PayType

Wednesday, 18 July 2012

Virtuemart 2.0 Related Products Css

Just a quick fix here to get all the related products on one line and get rid of the filename - without having to change any code.

just paste this into your css file

span.product-field-display{
float: left;
}

span.product-field-display a:link, span.product-field-display a:visited, span.product-field-display a:hover{
color: #666666;
    font-weight: bold;
}

span.vm-img-desc {
color: #fff;
}
If anyone goes further and make changes to the layout of Related Products itself I'd be interested to know as I couldn't find where the code for this was