我正在设置一个Symfony2应用程序,并试图使用Doctrine迁移。在此特定实例中,我试图为刚创建的实体客户端添加新表客户端。该表目前在数据库中不存在任何形式。
当我运行php app / console doctrine:migrations:diff时,出现以下错误:
[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'brand_id' on table 'clients'
Run Code Online (Sandbox Code Playgroud)
当然,没有该名称的列,该表尚不存在!
主义不应该认识到没有表格并创建表格吗?供参考,这是我的实体:
<?php
namespace RandomBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Client
*
* @ORM\Table(name="clients", indexes={@ORM\Index(name="brand_id", columns={"brand_id"})})
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class Client
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var \RandomBundle\Entity\Brand
*
* @ORM\ManyToOne(targetEntity="RandomBundle\Entity\Brand")
* @ORM\JoinColumns({
* …Run Code Online (Sandbox Code Playgroud) 完成Scala的初学者,并试图找出现在的基础知识.
作为教程的一部分,我正在尝试创建一个返回整数列表中最大元素的函数.为了实现这一点,我(暂时)将以下代码组合在一起:
def max(xs: List[Int]): Int =
if (xs.isEmpty)
throw new java.util.NoSuchElementException
else
findMax(xs.head, xs.tail)
def findMax(a: Int, b: List[Int]) {
if (b.isEmpty) return a
if (a > b.head)
findMax(a, b.tail)
else
findMax(b.head, b.tail)
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试编译它时,我得到第5行的类型错误.
[error] /scala/example/src/main/scala/example/Lists.scala:5: type mismatch;
[error] found : Unit
[error] required: Int
[error] findMax(xs.head, xs.tail)
Run Code Online (Sandbox Code Playgroud)
我不得不承认我对这个错误消息感到有点困惑,因为我不明白编译器是怎么认为我试图传递一个Unit类型给定逻辑以确保List在此行之前不为空.
任何人都可以帮助澄清这个问题吗?