我的表中有一列,我DECIMAL(19,4)正在为项目创建实体,定义这个字段的正确方法是什么?什么精度和规模的参数意味着主义注解?
我在我的控制器中有一个函数返回实体数组,所以在我的twig模板中我这样做迭代元素:
{% for groupName, entity in items %}
<ul>
<ul>
{% for element in entity %}
<li>{{ element.getLabel }}</li>
<li><input type="text" name="detail[{{ element.getId }}]" id="pd_{{ element.getId }}" /><input type="text" name="price[{{ element.getId }}]" id="pd_price_{{ element.getId }}" /><input type="text" name="stock[{{ element.getId }}]" id="pd_stock_{{ element.getId }}" /></li>
{% endfor %}
</ul>
</ul>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我也有这个PHP函数:
private function DetailCombination($arr, $level, &$result, $curr = array()) {
for ($i = 0; $i < count($arr); $i++) {
$new = array_merge($curr, array($arr[$i]));
if ($level == 1) { …Run Code Online (Sandbox Code Playgroud) 我正在使用EPPlus库并编写此代码(仅用于测试)
private void btnCargarExcel_Click(object sender, EventArgs e)
{
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
if (System.IO.File.Exists(openFileDialog1.FileName))
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
filePath.Text = openFileDialog1.FileName.ToString();
var existingFile = new FileInfo(openFileDialog1.FileName.ToString());
using (var package = new ExcelPackage(existingFile))
{
ExcelWorkbook workbook = package.Workbook;
if (workbook != null)
{
if (workbook.Worksheets.Count > 0)
{
ExcelWorksheet currentWorkSheet = workbook.Worksheets.First();
textBox3.Text = currentWorkSheet.Cells[0, 1].Value.ToString();
}
}
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
executiontime.Text =
String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10).ToString();
} …Run Code Online (Sandbox Code Playgroud) 因此,经过大量研究并得不到任何结果(也许我是一个不好的搜索者)我来自这个主题:SonataAdmin捆绑文件上传错误和SonataMediaBundle - 如何上传图像?我无法找到解决问题的方法.我有一个实体Company,每个公司可以有多个文件:PDF,DOC,XLS和其他一些mime /类型.我想要使用VichUploaderBundle但是文档只覆盖一对一关系的例子,所以我的问题是,任何可以给我一些例子或方法来完成这个吗?我的意思是上传文件并将它们附加到公司?
EDIT1工作和测试
正如我之前所说,我正在尝试将SonataMediaBundle集成到另一个管理模块中,但我无法让它工作.我到现在为止做了什么?
当然安装和配置所有捆绑包:SonataAdminBundle和SonataMediaBundle都工作正常
\Application\Sonata\MediaBundle\Entity\Media.php通过添加ManyToMany关系来修改类以添加所需的功能
namespace Application\Sonata\MediaBundle\Entity;
use Sonata\MediaBundle\Entity\BaseMedia as BaseMedia;
use Doctrine\ORM\Mapping as ORM;
class Media extends BaseMedia {
/**
* @var integer $id
*/
protected $id;
/**
* @ORM\ManyToMany(targetEntity="PL\OrderBundle\Entity\Order", inversedBy="medias")
* @ORM\JoinTable(name="order_has_media__media",
* joinColumns={@ORM\JoinColumn(name="media__media_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="order_no_order", referencedColumnName="no_order")}
* )
*/
protected $orders;
public function __construct() {
$this->orders = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer $id
*/
public function getId() { …Run Code Online (Sandbox Code Playgroud) 我试图通过运行任务生成一个简单的Doctrine2 CRUD,php app/console doctrine:generate:crud但我在它结束之前得到了这个错误:
[Doctrine\ORM\Mapping\MappingException]在'ProductBundle\Entity\ListHasProduct #list'中找不到目标实体ProductBundle\Entity\KList.
为什么它在寻找,如果在我的实体中我与该实体无关?这是我的实体代码:
<?php
namespace Wuelto\BankRulesBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Table(name="bank_rules")
* @ORM\Entity
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
class BankRules {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
*
* @ORM\ManyToOne(targetEntity="BankBundle\Entity\NBank" )
* @ORM\JoinColumn(name="n_bank", referencedColumnName="id")
*/
protected $n_bank;
/**
* @ORM\Column(type="string", length=255)
*/
protected $regex;
/**
* @ORM\Column(type="text")
*/
protected $action;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created", type="datetime")
*/
protected $created;
/**
* @Gedmo\Timestampable(on="update")
* @ORM\Column(name="modified", type="datetime") …Run Code Online (Sandbox Code Playgroud) 因此,我的任务是为简单的预订系统创建数据库模型,但我不知道如何在这里寻求帮助。到目前为止,我所做的只是图片所示,但是我不知道这是否足以从头开始构建简单的预订系统。我尝试Google寻找一些数据库设计,但没有发现任何帮助,有什么建议吗?您如何看待我的模特?缺少什么?

更新(基于答案) Ups我忘了告诉您需求是什么,然后我们开始:
sport_field可以在给定的小时和一天之内预订,这意味着,例如,用户不能预订sport_field两天或两天半的时间,而用户可以预订一小时,两小时,三小时或更长时间。(在这段时间以外,小时是从9:00 AM到11:00 PM的有效时间段,这是无效的-也许我会使用编程来隐藏)sport_field基于可用性的队列(由于这是预订系统的主要行为,也许我在这里也迷路了)sport_field最多将保留一天的预订时间,例如,用户可以预订sport_field,管理员将等待付款,如果付款未成功,则sport_field第二天将再次可用。
price是固定的,sport_field它永远不会改变,价格是每小时
active对我来说意味着如果将sport_field其保留一段时间或特定时间,则可能是我的设计错误并且不确定users 桌子来自另一个系统,我只是将预订部分添加到一个庞大的系统中,但是我需要使用他们的桌子更新2
根据建议,我将模型改进为:

更新3
根据建议的新变化:

我有两个实体:用户和公司,它们之间的关系是 n:m。在我的User.php实体中,我有以下代码:
/**
* @ORM\ManyToMany(targetEntity="PL\CompanyBundle\Entity\Company", mappedBy="users", cascade={"all"})
*/
protected $companies;
public function __construct() {
$this->companies = new \Doctrine\Common\Collections\ArrayCollection();
}
public function setCompanies(\PL\CompanyBundle\Entity\Company $companies) {
$this->companies = $companies;
}
public function getCompanies() {
return $this->companies;
}
Run Code Online (Sandbox Code Playgroud)
在我的Company.php实体中,我有其他代码:
/**
* @ORM\ManyToMany(targetEntity="Application\Sonata\UserBundle\Entity\User", mappedBy="companies")
*/
protected $users;
public function __construct() {
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}
Run Code Online (Sandbox Code Playgroud)
但我收到了这个错误:
ContextErrorException:注意:未定义索引:inverseJoinColumns in /var/www/html/apps/portal_de_logistica/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1041
映射有什么问题?
编辑重构代码
按照@ahmed-siouani 的指示,我进行了以下更改:
User.php
/**
* @ORM\ManyToMany(targetEntity="PL\CompanyBundle\Entity\Company", inversedBy="users")
* @ORM\JoinTable(name="fos_user_user_has_company",
* JoinColumns={@ORM\JoinColumn(name="fos_user_user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="company_id", referencedColumnName="id")}
* …Run Code Online (Sandbox Code Playgroud) 我需要以这种格式dd-mm-yyyy-hh-mm-ss格式化当前的DateTime,并且不知道该怎么做.我在Internet上阅读然后编写这段代码:
DateTime saveNow = DateTime.Now;
MessageBox.Show(String.Format("{0:u}", saveNow));
Run Code Online (Sandbox Code Playgroud)
但是这会返回此格式的日期:
2013-04-24 23:11:34Z
Run Code Online (Sandbox Code Playgroud)
可以帮助我吗?我需要第一种格式附加到我正在创建的文件名.
我定义了这个实体:
namespace CategoryBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity
* @ORM\Table(name="category")
*/
class Category {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
*/
protected $id;
/**
*
* @ORM\Column(type="string", length=255, nullable=false)
*/
protected $name;
/**
*
* @ORM\Column(type="integer", nullable=true)
*/
protected $parent;
/**
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $description;
/**
*
* @ORM\Column(type="integer")
*/
protected $age_limit;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(name="created", type="datetime")
*/
protected $created;
/**
* @Gedmo\Timestampable(on="update")
* @ORM\Column(name="modified", type="datetime")
*/ …Run Code Online (Sandbox Code Playgroud) symfony ×7
doctrine-orm ×4
symfony-2.3 ×4
.net ×2
c# ×2
database ×1
epplus ×1
mapping ×1
mysql ×1
orm ×1
php ×1
sonata ×1
sonata-admin ×1
twig ×1