Altough the Doctrine documentation about Working with associations states: "proper bidirectional association management in plain OOP is a non-trivial task and encapsulating all the details inside the classes can be challenging" I've used the following management methods (getters. setters, adders and removers) quite successfully.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION D_TO_HDM(value FLOAT, halfs TEXT) | |
RETURNS TEXT | |
RETURN CONCAT( | |
IF(value > 0, LEFT(halfs, 1), RIGHT(halfs, 1)), FLOOR(ABS(value+1/120000)) , ' ' | |
, LPAD(FLOOR((ABS(value+1/120000)-FLOOR(ABS(value+1/120000)))*60), 2, "0") , '.' | |
, LPAD(ROUND((ABS(value+1/120000)*60-FLOOR(ABS(value+1/120000)*60))*1000), 3, "0") | |
) | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION GC_ID_TO_CODE(p_id INT) | |
RETURNS TEXT | |
DETERMINISTIC | |
RETURN IF ( | |
p_id < 65536, | |
CONV(p_id, 10, 16), | |
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CONV(p_id+411120, 10, 31), | |
'U', 'Z'), 'T', 'Y'), 'S', 'X'), 'R', 'W'), 'Q', 'V'), 'P', 'T'), 'O', 'R'), 'N', 'Q'), 'M', 'P'), 'L', 'N'), 'K', 'M'), 'J', 'K'), 'I', 'J') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> | |
<meta name="robots" content="noindex, nofollow" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> | |
<title>Just a moment...</title> | |
<style type="text/css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Short Description --> | |
<img src="http://img.geocaching.com/76d138fb-5ca6-4c04-a816-b9432babb5cf.gif" width="18" height="12" alt="NL" /> | |
Een omgekeerde geocache, maar dan anders.<br /> | |
<!-- /Short Description --> | |
<br /> | |
<!-- Long Description --> | |
<img src="http://img.geocaching.com/36046a42-78d5-4721-a65e-f394309a446f.gif" width="18" height="12" alt="EN" /> | |
A reverse geocache, but different.<br /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Twig\Extension; | |
/** | |
* A TWIG Extension which allows to generate a range of excel columns | |
* Since excel works with column names instead of numbers a range of names is needed. | |
*/ | |
class ExcelExtension extends \Twig_Extension | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION wilson(stars INT, total INT) | |
RETURNS REAL DETERMINISTIC | |
RETURN IF ( | |
total, | |
( | |
(stars + 1.9208) / total - | |
1.96 * SQRT((stars * (total-stars)) / total + 0.9604) / total | |
) / (1 + 3.8416 / total), | |
0 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION distance (lat1 REAL, lng1 REAL, lat2 REAL, lng2 REAL) | |
RETURNS REAL DETERMINISTIC | |
RETURN 2 * 6371 * ASIN(SQRT( | |
SIN(RADIANS(lat1 - lat2)/2) * SIN(RADIANS(lat1 - lat2)/2) + | |
COS(RADIANS(lat1)) * COS(RADIANS(lat2)) * | |
SIN(RADIANS(lng1 - lng2)/2) * SIN(RADIANS(lng1 - lng2)/2) | |
)); |
Michaël Perrin has written an article about using annotation and filters improve security.
With a more complex model, for example an order that contains products, you want also to filter on the associations of the filtered entity.