}
- public function modelAction($actionData = false)
+ public function modelAction( $actionData = false )
{
// generate the stat entries
- $this->dailyStats();
+ //$this->dailyStats();
$this->weeklyStats();
- $this->monthlyStats();
+ //$this->monthlyStats();
echo 'done';
exit;
}
echo '<pre>$last_stat_date: ' . print_r( $last_stat_date, true ) . '</pre>';
$results = $this->wpdb->get_results(
$this->wpdb->prepare(
- "SELECT count(id) as leads_count,DATE_FORMAT(date_submitted, '%Y%U') as weekly
+ "SELECT count(id) as leads_count,DATE_FORMAT(date_submitted, '%%Y%%U') as weekly
FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_entry
WHERE date_submitted < %s
AND date_submitted > %s
GROUP BY weekly",
- current_time( 'mysql' ),
+ current_time( 'Y-m-d' ),
$last_stat_date
),
ARRAY_A
);
- echo '<pre>$results: ' . print_r( $results, true ) . '</pre>';
+ //echo '<pre>$sql: ' . print_r( $sql, true ) . '</pre>';
+ //echo '<pre>$num_rows: ' . print_r( $this->wpdb->num_rows, true ) . '</pre>';
+ echo '<pre>$time: ' . print_r( current_time( 'Y-m-d' ), true ) . '</pre>';
if ( $results ) {
- echo '<pre>$results: ' . print_r( $results, true ) . '</pre>';
- /*
+ //echo '<pre>$results: ' . print_r( $results, true ) . '</pre>';
foreach ( $results as $stat ) {
- if ( preg_match( '%/d{4}/d{2}%', $stat['weekly'], $matches ) ) {
- $date = new DateTime( $matches[1], $matches[2] );
+ if ( preg_match( '%(\d{4})(\d{2})%', $stat['weekly'], $matches ) ) {
+ echo '<pre>$matches: ' . print_r( $matches, true ) . '</pre>';
+ $date = date( "Y-m-d", strtotime( $matches[1]."W".$matches[2]."0" ) );
+ echo '<pre>$date: ' . print_r( $date, true ) . '</pre>';
} else {
return false;
}
- $this->wpdb->insert(
- GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . 'lead_stats',
- array(
- 'stat_type' => 'weekly',
- 'stat_date' => $date->format( 'P-m-d' ),
- 'leads_count' => $stat['leads_count']
- ),
- array(
- '%s',
- '%s',
- '%d'
- )
- );
+ if ( $date ) {
+ $this->wpdb->insert(
+ GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . 'lead_stats',
+ array(
+ 'stat_type' => 'weekly',
+ 'stat_date' => $date,
+ 'leads_count' => $stat['leads_count']
+ ),
+ array(
+ '%s',
+ '%s',
+ '%d'
+ )
+ );
+ }
}
- */
}
}