以下是请求:
$this->getEntityManager()->createQueryBuilder()
->select("trace.action")
->addSelect("concat(user.nom, ' ', user.prenom)")
->from('MyBundle:Ttrace', 'trace')
->innerjoin('trace', 'MyBundle:User', 'user', 'user.id = trace.user')
->where('trace.datfin is null');
有人可以使用queryBuilder翻译吗?
谢谢 我尝试了这个,但它不起作用:
$this->getEntityManager()->createQueryBuilder()
->select("trace.action")
->addSelect("concat(user.nom, ' ', user.prenom)")
->from('MyBundle:Ttrace', 'trace')
->join('MyBundle:User', 'user')
->where('trace.datfin is null');
但它不起作用。
我也尝试过:
var margin = {top: 40, right: 20, bottom: 30, left: 40},
width = 900,
height = 700;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.ticks(10)
.tickFormat(d3.format("s"));
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
return "<strong>Popularity:</strong> <span style='color:teal'>" + d.popularity+"</span>";
})
var svg = d3.select("#chart").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.call(tip);
function updateChart( concert){
d3.tsv(concert+".tsv", type, function(error, data) {
x.domain(data.map(function(d) { return d.month; }));
y.domain([0, 45]);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", "1em")
.style("text-anchor", "end")
.text("Popularity");
var pops= svg.selectAll(".bar")
.data(data)
.enter().append("rect")
.attr("width", x)
.attr("fill", function(d) {
if (d.popularity> 30) {
return "#010";
else
return "000";
})
.attr("class", "bar")
.attr("x", function(d) { return x(d.month); })
.attr("width", x.rangeBand())
.attr("y", height - 1)
.attr("height", 1);
pops.transition()
.duration(1000)
.delay(function (d, i) {
return i * 100;
})
.attr("y", function(d) { return y(d.popularity); })
.attr("height", function(d) { return height- y(d.popularity); });
pops.on('mouseover', tip.show)
.on('mouseout', tip.hide);
});
}
function type(d) {
d.popularity= +d.popularity;
return d;
}
但是sql查询错误: innerjoin用户on(trace.datfin为null)NONSENSE !!当然在sql查询中没有位置
那么,有人知道(他们很容易说)如何构建它(使用查询构建器)
TY
答案 0 :(得分:0)
希望它会帮助某人:
$qb = $this->getEntityManager()->createQueryBuilder()
->select('trace.action')
->addSelect("concat(user.nom, ' ', user.prenom)")
->from('MyBundle:Ttrace', 'trace');
$qb->join('MyBundle:User', 'u', Join::WITH, $qb->expr()->eq('trace.user', 'u.id'));
$qb->where($qb->expr()->isNull('trace.datfin');