问题描述
jenkins@k8s-worker1:/$ cat /etc/resolv.conf
search jenkins.svc.cluster.local svc.cluster.local cluster.local mydomain.org
nameserver 10.96.0.10
options ndots:5
jenkins@k8s-worker1:/$ cat /etc/hosts
# Kubernetes-managed hosts file (host network).
127.0.0.1 localhost
127.0.1.1 k8s-worker1
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
jenkins@k8s-worker1:/$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=17.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=10.3 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=10.2 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted,3 received,0% packet loss,time 2003ms
rtt min/avg/max/mdev = 10.293/12.738/17.569/3.417 ms
jenkins@k8s-worker1:/$ ping google.com
ping: google.com: Temporary failure in name resolution
然后在我的控制器中:
/**
* @param $firstname
* @param $lastname
* @return mixed
* @throws DBALException
*/
public function getListPerUser($firstname,$lastname)
{
$em = $this->getEntityManager();
$query = '
SELECT clientname
FROM contact_end_client c
INNER JOIN client_contract cli ON cli.clientname_id = c.id AND cli.active
INNER JOIN user u ON u.id = cli.user_id
WHERE u.firstname = :firstname AND u.lastname = :lastname AND cli.active = 1
';
$stmt = $em->getConnection()->prepare($query);
$param = ['firstname' => $firstname,'lastname' => $lastname];
$stmt->execute($param);
return $stmt->fetchAll();
}
如何给我返回一个json。 enter image description here 所以我认为我必须迭代吗? 但是我不知道如何在树枝上显示它。
/**
* @Route(path="/newadmin/invoice/showAllContract",name="showAllContract")
* @param Request $request
* @return JsonResponse
*/
public function viewContract(Request $request)
{
$entityManager = $this->getDoctrine()->getManager();
$template_id = $request->get('user');
//dump($template_id);
$getName = explode(" ",$template_id);
$firstname = $getName[0];
$lastname = $getName[1];
$templateRepository = $entityManager->getRepository(ClientContract::class)->getListPerUser($firstname,$lastname);
return new JsonResponse($templateRepository);
}
解决方法
cast(replace(col,','') as int)