小编ROB*_*BIN的帖子

PHP GD如何通过一行绘制文本

最终输出应该像图像(HELLO WORLD): 忽略线条厚度请..

这是我在做什么: -

$im = imagecreate(400,400); 

$txtcol = imagecolorallocate($im, 0xFF, 0x00, 0x00);

$size = 20;

$txt = 'DUMMY TEXT';

$font = './font/Capriola-Regular.ttf';

/*two points for base line*/

$x1 = 50; $x2 = 300; 

$y1 = 150; $y2 = 170;

/*bof finding line angle*/

$delta_x = $x2-$x1;

$delta_y = $y2-$y1;

$texangle = (rad2deg(atan2($delta_y,$delta_x)) * 180 / M_PI)-360;

/*eof finding the line angle*/


imageline($im,$x1,$y1,$x2,$y2,$txtcol); //Drawing line

imagettftext($im, $size, $texangle, $x1, $y1, $txtcol, $font, $txt); // Drawing text over line at line's …
Run Code Online (Sandbox Code Playgroud)

php gd

7
推荐指数
1
解决办法
1216
查看次数

Magento group by子句在日期字段中

我需要在指定月份的一天内获取'grand_total'的订单总数,SUM,MIN MAX和AVG.这就是我在做的事情.

$collection->getSelect()
               ->columns( 'SUM(base_grand_total) AS total' )
               ->columns( 'COUNT(*) AS orders_count' )
               ->columns( 'DATE_FORMAT(created_at, "%d") AS order_day' )
               ->columns( 'DATE_FORMAT(created_at, "%d/%m/%y") AS order_date' )
               ->columns( 'AVG(base_grand_total) AS avg_total' )
               ->columns( 'MAX(base_grand_total) AS max_total' )
               ->columns( 'MIN(base_grand_total) AS min_total' )
               ->where( 'DATE_FORMAT(created_at, "%m") = ?', $month )
               ->where( 'DATE_FORMAT(created_at, "%Y") = ?', $year )
               ->group( 'DATE_FORMAT(created_at, "%d-%m-%y")' );
Run Code Online (Sandbox Code Playgroud)

$ month是"Sep",$ year是"2014"

自定义网格系统上的上述查询的当前输出

什么销售>订单说同一时期

上面的查询说26日有3个订单,但是magento的Sales> Order网格表示只有一个订单在第26个.我猜答案在于," created_at "在DB中存储为"2014-09-04 02:50:04",但是如果我们将其格式化为"2014年9月3日下午4:50:04".

那么,任何人都可以建议如何在Collection上应用group by date子句.

提前致谢.

php mysql group-by magento

5
推荐指数
1
解决办法
1299
查看次数

标签 统计

php ×2

gd ×1

group-by ×1

magento ×1

mysql ×1