drop procedure if exists dump_image;
delimiter //
create procedure dump_image()
begin
declare this_id int;
declare cur1 cursor for select imageId from image;
open cur1;
read_loop: loop
fetch cur1 into this_id;
set @query = concat('select blob_field from image where imageId=',
this_id, ' into outfile "/tmp/xyz-', this_id,'.jpg"');
prepare write_file from @query;
execute write_file;
end loop;
close cur1;
end //
delimiter ;
select id,name, value from {table} where name = "";
select count (id) from {table} where value<{value_from_first}
$type = false;
foreach ($rows as $row){
if ($row['type']!=$type) {
$type = $row['type']; echo $type;
}
echo $row['name'];
}
static function distance($point1, $point2, $unit = 2 ) {
if (!$point2) return null;
if (!$point1) return null;
$point1 = explode(',', $point1);
$lon1 = $point1[0];
$lat1 = $point1[1];
$point2 = explode(',', $point2);
$lon2 = $point2[0];
$lat2 = $point2[1];
if ($lon1 == 0 || $lon2 == 0) {
return null;
}
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
switch ($unit) {
case(self::UNIT_KM) :
$out = $miles * 1.609344;
break;
case(self::UNIT_MI) :
$out = $miles;
break;
case(self::UNIT_NA) :
$out = $miles * 0.8684;
break;
}
return $out;
}
$response = [];
if ( have_posts() ){
while ( have_posts() ){
the_post();
$response['items'][]= 'elemnt';
}
}
T1::find()->andWhere(['id in ( select t2_id
from T2
where user_id = :user_id) ',['user_id'=>200]])->andWhere(['>', 'created_at', 0])->all()
select t1.*,t2.t2_id
from T1
left join t2 on
t2.t1_id = t1.id
where created_at > 0 and t2.user_id=200
T1::find()->leftJoin('t2','t2.t1_id = t1.id')->andWhere(['t2.user_id'=>'200'])->andWhere(['>', 'created_at', 0])->all()
T1::find()->joinWith(['t2'])->andWhere(['t2.user_id'=>'200'])->andWhere(['>', 'created_at', 0])->all()