CREATE PROCEDURE `sp_test`( in id int, in ofset int, in lmt int, out result int ) BEGIN DECLARE ch_done INT DEFAULT 0; declare program int; declare cur cursor for select name from users where ancestor = id LIMIT ofset, lmt; DECLARE CONTINUE HANDLER FOR NOT FOUND SET ch_done = 1; SET result = 0; open cur; start_loop: loop fetch cur into val; IF ch_done = 1 THEN LEAVE start_loop; END IF; SET result = 1; // SQL Queryies with val end loop; close cur; select result; END
Git Commands
- Caching your GitHub Credentials
- git config –global credential.helper ‘cache –timeout=300’
- Clean untracked file and directory
-
git clean -fdx
-
MySQL : Create a function to compare the two conman separated values
CREATE FUNCTION `FIND_IN_TWO_SET`(val TEXT, val2 TEXT) RETURNS int(11) BEGIN DECLARE output TEXT; DECLARE inc INT; DECLARE mach INT; SET inc = 0; SET mach = 0; label1: LOOP SET inc = inc + 1; SET output = REPLACE(SUBSTRING(SUBSTRING_INDEX(val, ',', inc), CHAR_LENGTH(SUBSTRING_INDEX(val, ',', inc - 1)) + 1), ',', ''); IF output = '' THEN SET output = null; LEAVE label1; END IF; if find_in_set(output, val2) > 0 THEN SET mach = 1; LEAVE label1; END IF; ITERATE label1; END LOOP label1; RETURN mach; END
PHP : convert date to another time zone
function converToTz($time=””,$toTz=”,$fromTz=”)
{
// timezone by php friendly values
$date = new DateTime($time, new DateTimeZone($fromTz));
$date->setTimezone(new DateTimeZone($toTz));
$time= $date->format(‘Y-m-d H:i:s’);
return $time;
}
echo date_default_timezone_get();
echo converToTz(‘2019-08-07 13:00:00’, ‘UTC’, ‘Asia/Calcutta’);
Doctrine : Get uncommitted transaction data
$em->beginTransaction();
$tx = $em->getConnection();
$lavel = $tx->getTransactionIsolation();
$tx->setTransactionIsolation(1);
$em->persist($data);
//Set of code
$tx->setTransactionIsolation($lavel);
$em->flush();
$em->commit();