我不知道为什么,但是当我从symfony应用程序查看一个页面时,它崩溃了这个错误:Symfony 3.2 Crash with Error' vendor / doctrine / dbal / lib / Doctrine / DBAL /第91行'上的Driver / PDOStatement.php。它并不是一个非常复杂的页面,而且以前工作得很好。
控制器:
public function showAction($motorId)
{
$em = $this->getDoctrine()->getManager();
$motor = $em->getRepository('AppBundle:motors')
->findOneBy(['id' => $motorId]);
if (!$motor) {
throw $this->createNotFoundException('motor not found');
}
$motorImage = $motor->getImageName();
return $this->render('motors/motorView.html.twig', array(
'm' => $motor,
'image' => $motorImage
));
}
树枝模板:
{% extends 'base.html.twig' %}
{% block body %}
<div class="row">
<!-- Motors -->
{% if m.make is not empty %}
<div class="col-sm-6">
<h3>Motor</h3>
<ul>
<li>Make: {{ m.make }}</li>
<li>HP: {{ m.hp }}</li>
<li>Year: {{ m.year }}</li>
<li>Model: {{ m.model }}</li>
<li>Serial: {{ m.serial }}</li>
<li>Cycle: {{ m.cycle }}</li>
<li>Shaft Length: {{ m.shaft }}</li>
<li>Condition: {{ m.motorCondition }}</li>
<li>Category: {{ m.motorCategory }}</li>
<li>Rotation: {{ m.rotation }}</li>
<li>Compression: {{ m.compression }}</li>
<li>Owner: {{ m.owner }}</li>
<li>On Boat: {{ m.onBoat }}</li>
</ul>
</div>
<div class="col-sm-6">
{% if m.customer %}
<h3>Purchase Details</h3>
<ul>
<li>Name: {{ m.customer.name }}</li>
<li>Phone: {{ m.customer.phone1 }}</li>
<li>Address: {{ m.customer.address1 }}</li>
<li>City: {{ m.customer.city }}</li>
<li>State: {{ m.customer.state }}</li>
<li>Zip: {{ m.customer.zip }}</li>
{#
<li>Purchase Price: {{ m.tpurchasePrice }}</li>
<li>Date Acquired: {{ m.tDateAcquired|date('m/d/y h:ia') }}</li>
#}
</ul>
{% endif %}
</div>
{% endif %}
</div>
<div class="row">
<div class="col-sm-3">
<a href="{{ path('motor_list') }}" >Back to List</a>
</div>
<div class="col-sm-3">
<a href="{{ path('edit_motor', {'id': m.id}) }}">Edit</a>
</div>
</div>
{#
{% if image is not empty %}
<a href="#" data-toggle="modal" data-target=".bs-example-modal-lg" >
<img src="{{ asset('upload/motors/' ~ image) }}" style="max-height: 150px; border: 1px solid;"></img>
</a>
{% endif %}
#}
{% endblock %}
有趣的是,它只是导致问题的一个项目。这是转储信息:
motors {#1860 ▼
-id: 10
-make: "Yamaha"
-hp: "250"
-year: "2012"
-model: "f250txr"
-serial: "yamahaserial123"
-cycle: "4"
-motorCondition: "Like New"
-motorCategory: "Outboard"
-details: null
-shaft: "25"
-rotation: "Standard"
-compression: "180, 180, 180, 180, 180, 180"
-price: null
-owner: "Banana Monster"
-customer: customers {#1936 ▶}
-createdBy: "keyboard smasher"
-purchasePrice: "5000"
-dateAcquired: DateTime {#1856 ▼
+"date": "2017-06-01 00:00:00.000000"
+"timezone_type": 3
+"timezone": "America/New_York"
}
-mStatus: null
-imageFile: null
-imageName: null
-updatedAt: DateTime {#1857 ▶}
-onBoat: 0
-boat: PersistentCollection {#1928 ▶}
-saleItem: PersistentCollection {#2000 ▶}
-boats: null
这是用于比较的另一个:
motors {#573 ▼
-id: 5
-make: "Yamaha"
-hp: "250"
-year: "2005"
-model: "F250TXR"
-serial: "YMS102RL192"
-cycle: "4"
-motorCondition: null
-motorCategory: "Outboard"
-details: null
-shaft: "25"
-rotation: null
-compression: null
-price: null
-owner: "Banana Bandit"
-customer: null
-createdBy: "keyboard smasher"
-purchasePrice: null
-dateAcquired: null
-mStatus: null
-imageFile: null
-imageName: null
-updatedAt: DateTime {#570 ▶}
-onBoat: 0
-boat: PersistentCollection {#582 ▶}
-saleItem: PersistentCollection {#703 ▶}
-boats: null
任何想法会使这个特定项目如此合适?
答案 0 :(得分:0)
试试这个:
$motor = $em->getRepository('AppBundle:motors')
->find($motorId);
而不是:
$motor = $em->getRepository('AppBundle:motors')
->findOneBy(['id' => $motorId]);