我在下面有这个查询:
SELECT *
FROM mydb.users
left join mydb.jobs
on users.user_id = jobs.job_id;
我曾经在orm查询中转换它们,如下所示:
return
$qb = $this->entityManager->createQueryBuilder();
$qb->select('rb', 'l')
->from('Admin\Entity\Users', 'rb')
->leftJoin(
'Admin\Entity\Jobs',
'l',
\Doctrine\ORM\Query\Expr\Join::WITH,
'rb.user_id = l.job_id'
)
->getQuery()
->getResult(AbstractQuery::HYDRATE_ARRAY);
但它仍然有效。我收到以下错误:
PHP Fatal error: Call to a member function createQueryBuilder() on null
请帮助我不知道该怎么做。
答案 0 :(得分:1)
试试这个
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
或确保已分配$ this-> entityManager。
答案 1 :(得分:1)
这只是意味着您在 public static String excutePost(String targetURL, String urlParameters)
{
URL url;
HttpURLConnection connection = null;
try {
//Create connection
url = new URL(targetURL);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", "" +
Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches (false);
connection.setDoInput(true);
connection.setDoOutput(true);
//Send request
DataOutputStream wr = new DataOutputStream (
connection.getOutputStream ());
wr.writeBytes (urlParameters);
wr.flush ();
wr.close ();
//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
return response.toString();
} catch (Exception e) {
String g=e.toString();
Log.d("errererer", g);
return null;
} finally {
if(connection != null) {
connection.disconnect();
}
}
}
中没有EntityManager
个实例。
我的猜测是$this->entityManager
可能为null,因为你没有在类实例中注入$this->entityManager
。