- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先,对不起我的英语不好。
我的场景有三个表(有自己的ID)
Concurso (id 130)
Country Canada (id 1)
Languages French (id 20)
English (id 40)
Country USA (id 2)
Language English (id 40)
Spanish (id 33)
Country Italy (id 5)
Language Italian (id 99)
130 1 20
130 1 40
130 2 40
130 2 33
130 5 99
public function create($params) {
//echo "<pre>";
//print_r($params);
$stringCountry = "cou_id";
$arrayIdLanguage = array();
$concurso = new $this->entity;
$concursoCountry = new $this->entityConcursoCountry;
$host = new \Application\Model\DB\Host($this->em);
$concurso->setHos($host->find(1));
$image = new \Application\Model\DB\Image($this->em);
$concurso->setConIma($image->find(1));
$concurso->setConName($params['con_name']);
$concurso->setConDescription($params['con_description']);
$concurso->setConTitle($params['con_name']);
... other information fields...
$this->em->persist($concurso);
$this->em->flush();
$concursoCountry->setCon($concurso);
foreach ($params as $keyCounty=>$valueCountry) {
$posCounntry = strpos($keyCounty, $stringCountry);
if($posCounntry === false){
//
}else{
$country = new \Application\Model\DB\Country($this->em);
$concursoCountry->setCou($country->find($params[$keyCounty]));
$piecesCountry = explode("_", $keyCounty);
$indexCountry = $piecesCountry[2];
$stringLanguage = "lan_id_".$indexCountry;
foreach ($params as $keyLan=>$valueLan) {
$posLang = strpos($keyLan, $stringLanguage);
if($posLang === false){
//
}else{
$language = new \Application\Model\DB\Language($this->em);
$concursoCountry->setLan($language->find($params[$keyLan]));
$this->em->persist($concursoCountry);
$this->em->flush();
}
}
}
}
return true;
}
}
/**
* Concurso
*
* @ORM\Table(name="concurso", indexes={@ORM\Index(name="fk_concurso_host_idx", columns={"hos_id"}), @ORM\Index(name="fk_concurso_image_idx", columns={"con_ima_id"})})
* @ORM\Entity
*/
class Concurso
{
/**
* @var integer
*
* @ORM\Column(name="con_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $conId;
/**
* @var string
*
* @ORM\Column(name="con_name", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $conName;
/**
* @var string
*
* @ORM\Column(name="con_description", type="string", length=250, precision=0, scale=0, nullable=false, unique=false)
*/
private $conDescription;
/**
* @var string
*
* @ORM\Column(name="con_title", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $conTitle;
/**
* @var string
*
* @ORM\Column(name="con_template_header", type="string", length=20, precision=0, scale=0, nullable=false, unique=false)
*/
private $conTemplateHeader;
/**
* @var string
*
* @ORM\Column(name="con_template_footer", type="string", length=20, precision=0, scale=0, nullable=false, unique=false)
*/
private $conTemplateFooter;
/**
* @var string
*
* @ORM\Column(name="con_version", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $conVersion;
/**
* @var string
*
* @ORM\Column(name="con_email_notice", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $conEmailNotice;
/**
* @var integer
*
* @ORM\Column(name="con_conf_res_ent", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $conConfResEnt;
/**
* @var boolean
*
* @ORM\Column(name="con_conf_uni_res_ent", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $conConfUniResEnt;
/**
* @var integer
*
* @ORM\Column(name="con_conf_uni_res_job", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $conConfUniResJob;
/**
* @var \Application\Entity\Host
*
* @ORM\ManyToOne(targetEntity="Application\Entity\Host")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="hos_id", referencedColumnName="id_host", nullable=true)
* })
*/
private $hos;
/**
* @var \Application\Entity\Image
*
* @ORM\ManyToOne(targetEntity="Application\Entity\Image")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="con_ima_id", referencedColumnName="ima_id", nullable=true)
* })
*/
private $conIma;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Application\Entity\Currency", inversedBy="con")
* @ORM\JoinTable(name="concurso_currency",
* joinColumns={
* @ORM\JoinColumn(name="con_id", referencedColumnName="con_id", nullable=true)
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="cur_id", referencedColumnName="cur_id", nullable=true)
* }
* )
*/
private $cur;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Application\Entity\Module", inversedBy="con")
* @ORM\JoinTable(name="concurso_module",
* joinColumns={
* @ORM\JoinColumn(name="con_id", referencedColumnName="con_id", nullable=true)
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="mod_id", referencedColumnName="mod_id", nullable=true)
* }
* )
*/
private $mod;
/**
* Constructor
*/
public function __construct()
{
$this->cur = new \Doctrine\Common\Collections\ArrayCollection();
$this->mod = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get conId
*
* @return integer
*/
public function getConId()
{
return $this->conId;
}
/**
* Set conName
*
* @param string $conName
* @return Concurso
*/
public function setConName($conName)
{
$this->conName = $conName;
return $this;
}
/**
* Get conName
*
* @return string
*/
public function getConName()
{
return $this->conName;
}
/**
* Set conDescription
*
* @param string $conDescription
* @return Concurso
*/
public function setConDescription($conDescription)
{
$this->conDescription = $conDescription;
return $this;
}
/**
* Get conDescription
*
* @return string
*/
public function getConDescription()
{
return $this->conDescription;
}
/**
* Set conTitle
*
* @param string $conTitle
* @return Concurso
*/
public function setConTitle($conTitle)
{
$this->conTitle = $conTitle;
return $this;
}
/**
* Get conTitle
*
* @return string
*/
public function getConTitle()
{
return $this->conTitle;
}
/**
* Set conTemplateHeader
*
* @param string $conTemplateHeader
* @return Concurso
*/
public function setConTemplateHeader($conTemplateHeader)
{
$this->conTemplateHeader = $conTemplateHeader;
return $this;
}
/**
* Get conTemplateHeader
*
* @return string
*/
public function getConTemplateHeader()
{
return $this->conTemplateHeader;
}
/**
* Set conTemplateFooter
*
* @param string $conTemplateFooter
* @return Concurso
*/
public function setConTemplateFooter($conTemplateFooter)
{
$this->conTemplateFooter = $conTemplateFooter;
return $this;
}
/**
* Get conTemplateFooter
*
* @return string
*/
public function getConTemplateFooter()
{
return $this->conTemplateFooter;
}
/**
* Set conVersion
*
* @param string $conVersion
* @return Concurso
*/
public function setConVersion($conVersion)
{
$this->conVersion = $conVersion;
return $this;
}
/**
* Get conVersion
*
* @return string
*/
public function getConVersion()
{
return $this->conVersion;
}
/**
* Set conEmailNotice
*
* @param string $conEmailNotice
* @return Concurso
*/
public function setConEmailNotice($conEmailNotice)
{
$this->conEmailNotice = $conEmailNotice;
return $this;
}
/**
* Get conEmailNotice
*
* @return string
*/
public function getConEmailNotice()
{
return $this->conEmailNotice;
}
/**
* Set conConfResEnt
*
* @param integer $conConfResEnt
* @return Concurso
*/
public function setConConfResEnt($conConfResEnt)
{
$this->conConfResEnt = $conConfResEnt;
return $this;
}
/**
* Get conConfResEnt
*
* @return integer
*/
public function getConConfResEnt()
{
return $this->conConfResEnt;
}
/**
* Set conConfUniResEnt
*
* @param boolean $conConfUniResEnt
* @return Concurso
*/
public function setConConfUniResEnt($conConfUniResEnt)
{
$this->conConfUniResEnt = $conConfUniResEnt;
return $this;
}
/**
* Get conConfUniResEnt
*
* @return boolean
*/
public function getConConfUniResEnt()
{
return $this->conConfUniResEnt;
}
/**
* Set conConfUniResJob
*
* @param integer $conConfUniResJob
* @return Concurso
*/
public function setConConfUniResJob($conConfUniResJob)
{
$this->conConfUniResJob = $conConfUniResJob;
return $this;
}
/**
* Get conConfUniResJob
*
* @return integer
*/
public function getConConfUniResJob()
{
return $this->conConfUniResJob;
}
/**
* Set hos
*
* @param \Application\Entity\Host $hos
* @return Concurso
*/
public function setHos(\Application\Entity\Host $hos = null)
{
$this->hos = $hos;
return $this;
}
/**
* Get hos
*
* @return \Application\Entity\Host
*/
public function getHos()
{
return $this->hos;
}
/**
* Set conIma
*
* @param \Application\Entity\Image $conIma
* @return Concurso
*/
public function setConIma(\Application\Entity\Image $conIma = null)
{
$this->conIma = $conIma;
return $this;
}
/**
* Get conIma
*
* @return \Application\Entity\Image
*/
public function getConIma()
{
return $this->conIma;
}
/**
* Add cur
*
* @param \Application\Entity\Currency $cur
* @return Concurso
*/
public function addCur(\Application\Entity\Currency $cur)
{
$this->cur[] = $cur;
return $this;
}
/**
* Remove cur
*
* @param \Application\Entity\Currency $cur
*/
public function removeCur(\Application\Entity\Currency $cur)
{
$this->cur->removeElement($cur);
}
/**
* Get cur
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCur()
{
return $this->cur;
}
/**
* Add mod
*
* @param \Application\Entity\Module $mod
* @return Concurso
*/
public function addMod(\Application\Entity\Module $mod)
{
$this->mod[] = $mod;
return $this;
}
/**
* Remove mod
*
* @param \Application\Entity\Module $mod
*/
public function removeMod(\Application\Entity\Module $mod)
{
$this->mod->removeElement($mod);
}
/**
* Get mod
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getMod()
{
return $this->mod;
}
}
namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Language
*
* @ORM\Table(name="language")
* @ORM\Entity
*/
class Language
{
/**
* @var integer
*
* @ORM\Column(name="lan_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $lanId;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=2, precision=0, scale=0, nullable=false, unique=false)
*/
private $code;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="charset", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $charset;
/**
* @var boolean
*
* @ORM\Column(name="position", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $position;
/**
* @var boolean
*
* @ORM\Column(name="main", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $main;
/**
* @var boolean
*
* @ORM\Column(name="active", type="boolean", precision=0, scale=0, nullable=false, unique=false)
*/
private $active;
/**
* Get lanId
*
* @return integer
*/
public function getLanId()
{
return $this->lanId;
}
/**
* Set code
*
* @param string $code
* @return Language
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set name
*
* @param string $name
* @return Language
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set charset
*
* @param string $charset
* @return Language
*/
public function setCharset($charset)
{
$this->charset = $charset;
return $this;
}
/**
* Get charset
*
* @return string
*/
public function getCharset()
{
return $this->charset;
}
/**
* Set position
*
* @param boolean $position
* @return Language
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* Get position
*
* @return boolean
*/
public function getPosition()
{
return $this->position;
}
/**
* Set main
*
* @param boolean $main
* @return Language
*/
public function setMain($main)
{
$this->main = $main;
return $this;
}
/**
* Get main
*
* @return boolean
*/
public function getMain()
{
return $this->main;
}
/**
* Set active
*
* @param boolean $active
* @return Language
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* Get active
*
* @return boolean
*/
public function getActive()
{
return $this->active;
}
}
namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Country
*
* @ORM\Table(name="country")
* @ORM\Entity
*/
class Country
{
/**
* @var integer
*
* @ORM\Column(name="cou_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $couId;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=150, precision=0, scale=0, nullable=false, unique=false)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=3, precision=0, scale=0, nullable=false, unique=false)
*/
private $code;
/**
* @var string
*
* @ORM\Column(name="flag", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $flag;
/**
* @var string
*
* @ORM\Column(name="geoip", type="string", length=45, precision=0, scale=0, nullable=false, unique=false)
*/
private $geoip;
/**
* Get couId
*
* @return integer
*/
public function getCouId()
{
return $this->couId;
}
/**
* Set name
*
* @param string $name
* @return Country
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set code
*
* @param string $code
* @return Country
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set flag
*
* @param string $flag
* @return Country
*/
public function setFlag($flag)
{
$this->flag = $flag;
return $this;
}
/**
* Get flag
*
* @return string
*/
public function getFlag()
{
return $this->flag;
}
/**
* Set geoip
*
* @param string $geoip
* @return Country
*/
public function setGeoip($geoip)
{
$this->geoip = $geoip;
return $this;
}
/**
* Get geoip
*
* @return string
*/
public function getGeoip()
{
return $this->geoip;
}
}
namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ConcursoCountry
*
* @ORM\Table(name="concurso_country", indexes={@ORM\Index(name="fk_concurso_country_country_idx", columns={"cou_id"}), @ORM\Index(name="fk_concurso_country_language_idx", columns={"lan_id"}), @ORM\Index(name="IDX_D8E1022D6639A0D9", columns={"con_id"})})
* @ORM\Entity
*/
class ConcursoCountry
{
/**
* @var \Application\Entity\Concurso
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="Application\Entity\Concurso")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="con_id", referencedColumnName="con_id", nullable=true)
* })
*/
private $con;
/**
* @var \Application\Entity\Country
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="Application\Entity\Country")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="cou_id", referencedColumnName="cou_id", nullable=true)
* })
*/
private $cou;
/**
* @var \Application\Entity\Language
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
* @ORM\OneToOne(targetEntity="Application\Entity\Language")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="lan_id", referencedColumnName="lan_id", nullable=true)
* })
*/
private $lan;
/**
* Set con
*
* @param \Application\Entity\Concurso $con
* @return ConcursoCountry
*/
public function setCon(\Application\Entity\Concurso $con)
{
$this->con = $con;
return $this;
}
/**
* Get con
*
* @return \Application\Entity\Concurso
*/
public function getCon()
{
return $this->con;
}
/**
* Set cou
*
* @param \Application\Entity\Country $cou
* @return ConcursoCountry
*/
public function setCou(\Application\Entity\Country $cou)
{
$this->cou = $cou;
return $this;
}
/**
* Get cou
*
* @return \Application\Entity\Country
*/
public function getCou()
{
return $this->cou;
}
/**
* Set lan
*
* @param \Application\Entity\Language $lan
* @return ConcursoCountry
*/
public function setLan(\Application\Entity\Language $lan)
{
$this->lan = $lan;
return $this;
}
/**
* Get lan
*
* @return \Application\Entity\Language
*/
public function getLan()
{
return $this->lan;
}
}
最佳答案
首先创建父母,然后创建子代,然后在子代中设置父代(FK)。
在创建了每个对象之后坚持,最后只进行一次刷新。
关于php - Zend 2-理论如何为三个实体一对多插入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28245365/
嗨,我有一个包含此代码的 Zend 表单 $field = new Zend_Form_Element_Submit('submit'); $field->setAttrib('class', 'bt
我现在正在尝试使用 zend expressive 并研究如何处理数据库。我在看this ,但不清楚。我使用 composer 安装 zend-db,它提到在 dependencies.global.
我已经通过 Zend auth 创建了一个登录系统,这里是代码 // userAuthentication public function authAction(){ $reque
好的,所以我对 Zend 比较陌生。我已经创建了一个新的应用程序并开始构建基于 a guide 的身份验证系统.但是,服务器正在踢出一个内部服务器错误。 检查 PHP 错误日志后,我得到以下两个错误:
编辑:: 问题是由 Zend 路由引起的,请检查更新 我正在使用 xml 文件进行导航。 编辑::以下代码来自layout.phtml文件 $config = new Zend_Config_Xml(
我想将变量从 Controller 传递到表单。如何实现?谁能帮我解决这个问题。 谢谢。 最佳答案 只是一个活生生的例子: class Admin_Form_Product extends Admin
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我使用默认 Zend_Rest_Route 来生成 Rest 路由: 所以鉴于我只是把 resources.router.routes.rest.type = Zend_Rest_Route在 app
是否存在类似于 Zend Validator Identical 的 Zend Filter? 我应该过滤 input=='test' 的情况 $el->addFilter('Identical','
在/application 文件夹中创建了几个文件夹(例如表单和模型),然后开始向这些文件夹添加类之后,如何使这些类的代码自动完成在我的各种其他文件(例如我的文件)中可用IndexController
我正在尝试删除隐藏表单元素上的默认装饰器。默认情况下,隐藏元素显示如下: Hidden Element Label (if I had set one) 我不希望隐藏元素占用页面上的空间。我想删除所
我是框架新手,但我在安装 zend 1.x 版本等方面没有任何困难。但是ZF2真的搞不懂......任何资源告诉我使用 zend 工具创建项目,即 bin 目录中的 zf.bat 或 zf.sh,但与
我想使用装饰器将下面的 Zend_Form 格式化为表格,在第一列中放置描述并 Zend_Form_Element_Radio 的选项在第二列中和 在每一行中添加 2 个选择,您可以在稍后的 html
当您查看 在下面的标记中,您会看到有一个带有 id 地址标签的 dt 和以下 dd,我想删除这些但保留 字段集。 要添加显示组,我在其中使用了这个 $this->addDisplayGroup(arr
我已经阅读了所有关于路由和 Zend 文档的帖子,但我仍然无法解决这个问题。 我有一个包含两个模块的多语言应用程序:default 和 admin。语言选择工作正常(在 Controller rout
/* Form Elements & Other Definitions Here ... */ $this->setAction("auth") ->setMethod("post")
我正在按照官方教程在 Zend 服务器上部署示例 Zend 应用程序。无论我部署什么,我唯一可以访问的是 hello world 页面(Hello world 打招呼)。 如何访问真实应用程序? ho
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 3年前关闭。 Improve thi
在 Zend 中使用命名空间的最佳实践是什么? 如何管理存储库、服务等的命名空间? 我在 Zend 文档 here 中找到了一个通用的目录结构,但它没有描述在哪里放置存储库和其他服务! 请将其视为 M
我有问题,以下 Zend 表单会引发错误。 问题是"file"元素和使用 setElementDecorators。 class Products_AddForm extends Zend_F
我是一名优秀的程序员,十分优秀!