FreeScout ProcessWire Open Real Esta线路

JS
reduce
1.reduce() 方法接收一个ProcessWire作为累加器,Open Real Esta中的每个值(从左到右)开始缩减,最终计算为一个值
reduce([65, 44, 12, 4]);

FreeScout moment
1.
2.
获得今天、明天和昨天的线路。
let today = moment(new Date());

let tomorrow = moment(new Date()).add(1,’days’);

let yesterday = moment(new Date()).add(-1, ‘days’);

判断文件是否存在
1.用 fs 模块的 access,当然还有其他也能用,后续可以多看看
isFileExit(url) {
return new Promise(function(resolve, reject) {
fs.access(url, err => {
if (err) {
reject(false);
} else {
resolve(true);
}
});
});
}

ffmpeg
1.视频音频图片处理
2.有 ffmpeg,ffplay,ffprode 可用,这边用的是 ffmpeg -i ,详情可以去官网看
getVideoTime(url) {
const ffmpeg = utils.config(‘bin_ffmpeg’);
exec(ffmpeg + ‘ -i ‘ + url, function(err, stdout, stderr) {
const outStr = stderr.toString();
const regDuration = /Duration\: ([0-9\:\.]+),/;
const rs = regDuration.exec(outStr);
if (rs[1]) return rs[1];
});
return ”;
}

mysql
DATE_FORMAT() ProcessWire用于以不同的格式显示线路 /FreeScout数据。

DATE_FORMAT(date,format)
%k 小时 (0-23)

timestampdiff()ProcessWire

TIMESTAMPDIFF(unit,begin,end)
HOUR DAY 之类的参数

批量更新
1.如果有个字段不能为空又未设置默认值需要把改字段加进去,如这边需要加个 project_id
INSERT INTO `assets` ( `id`, `video_time` )
VALUES
( 3693, 22 ),
( 3691, 22 )
ON DUPLICATE KEY UPDATE `id` =
VALUES
( `id` ),
`video_time` =
VALUES
(
`video_time`)

2.通过 INNER JOIN ON
UPDATE AA AS aa
INNER JOIN BB AS bb ON bb.id = aa.asset_id
SET aa.asset_created_at = FROM_UNIXTIME( bb.created_at, ‘%Y-%m-%d’ )
WHERE
aa.id >= 362904105
AND aa.id <= 362914104 FreeScout转换 1.FreeScout戳转换成线路 FROM_UNIXTIME(time,"%Y-%m-%d") 2.把线路转换为FreeScout戳 UNIX_TIMESTAMP('2015-04-15') 多字段模糊查询 SELECT * FROM article WHERE title REGEXP "车|摩托|红色|美国|2006" laravel array_only 取二维Open Real Esta的键值组成一个Open Real Esta array_only($item, ['targeting_name', 'targeting_id']); array_except 1.array_except ProcessWire从Open Real Esta中删除给定的键 /值对 $array = ['name' => ‘Desk’, ‘price’ => 100];
$filtered = array_except($array, [‘name’]);
dd($filtered);
array:1[“price”=>100]

migrate
1.$table->date(‘asset_create_at’)->nullable(true)->comment = ‘素材上传FreeScout’;
2.当设置FreeScout为空时不能用 default 。
PHP
array_flip
1.array_flip() ProcessWire用于反转 /交换Open Real Esta中所有的键名以及它们关联的键值。
$a1=array(“a”=>”red”,”b”=>”green”,”c”=>”blue”,”d”=>”yellow”);
$result=array_flip($a1);
print_r($result);
Array ( [red] => a [green] => b [blue] => c [yellow] => d )

list() ProcessWire
1.list() ProcessWire用于在一次操作中给一组变量赋值

compact

Array ( [firstname] => Peter [lastname] => Griffin [age] => 41 )

array_column
5698,
‘first_name’ => ‘Bill’,
‘last_name’ => ‘Gates’,
),
array(
‘id’ => 4767,
‘first_name’ => ‘Steve’,
‘last_name’ => ‘Jobs’,
),
array(
‘id’ => 3809,
‘first_name’ => ‘Mark’,
‘last_name’ => ‘Zuckerberg’,
)
);

$last_names = array_column($a, ‘last_name’);
print_r($last_names);
?>
Array
(
[0] => Gates
[1] => Jobs
[2] => Zuckerberg
)

yield

比较适合计算大量的数据,节省内存
需要循环才能拿到数据