在本文中,我们将带你了解php–自动为Doctrine生成getset方法在这篇文章中,我们将为您详细介绍php–自动为Doctrine生成getset方法的方方面面,并解答php自动生成文章常见的疑
在本文中,我们将带你了解php – 自动为Doctrine生成get set方法在这篇文章中,我们将为您详细介绍php – 自动为Doctrine生成get set方法的方方面面,并解答php自动生成文章常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的delphi – 如何自动生成getter和setter方法、Doctrine CLI输出doctrine.php的内容、doctrine-orm – Doctrine 2:写一个合适的Subselect、doctrine2 – Doctrine 2 fetch =“EAGER”。
本文目录一览:- php – 自动为Doctrine生成get set方法(php自动生成文章)
- delphi – 如何自动生成getter和setter方法
- Doctrine CLI输出doctrine.php的内容
- doctrine-orm – Doctrine 2:写一个合适的Subselect
- doctrine2 – Doctrine 2 fetch =“EAGER”
php – 自动为Doctrine生成get set方法(php自动生成文章)
我设置和属性如下:
/** * @var string $name * * @Column(name="Name",type="string",length=100,nullable=false) */ private $name;
获得& set方法由信息构成,完全包含在属性声明中.所以有人知道任何可以从属性声明中生成如下所示的get set方法的工具.
/** * Set name * * @param string $name * @return User */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; }
在学说文档中我找到了this工具(实体生成),但我无法理解我应该做什么.
解决方法
delphi – 如何自动生成getter和setter方法
>我定义了一个局部变量// 1
>我创建了一个属性// 2
>我按下CTRL SHIFT C并且编辑器创建getter和setter方法// 3
对于这个例子:
unit Unit1; type ClassePippo=class private colorText:string; //1 function getColorText: String; //3 procedure setColorText(const Value: String); //3 public property colore: String read getColorText write setColorText; //2 end; implementation { ClassePippo } function ClassePippo.getColorText: String; //3 begin Result:=colorText; end; procedure ClassePippo.setColorText(const Value: String); //3 begin colorText:=Value; end; end.
是否有自动创建getter和setter方法的功能?
我只想写colorText:string; // 1并调用快捷方式,我希望IDE自动创建// 2和// 3.
(当我使用Eclipse在Java中开发时,我可以使用Source自动生成getter和setter方法 – >生成getter和setter ……)
解决方法
Property Colore:String Read GetColorText Write SetColorText;
然后按Ctrl Shift C.
然后,IDE将创建getter,setter和private内部变量.
请注意,Property Paster中的Property setter和getter是可选的.你可以轻松写
Property Colore:String Read FColorText Write FColorText;
或只有一个二传手或吸气剂
Property Colore:String读取FColorText写入SetColorText;
在这种情况下,IDE将生成私有FColorText变量和setter方法SetColorText
Doctrine CLI输出doctrine.php的内容
#!/usr/bin/env sh SRC_DIR="`pwd`" cd "`dirname "$0"`" cd "../doctrine/orm/bin" BIN_TARGET="`pwd`/doctrine.PHP" cd "$SRC_DIR" "$BIN_TARGET" "$@"
这是doctrine.PHP的内容,我用代码frome教程替换了.
转到项目的根目录,然后键入:
PHP path_to_doctrine_bin/doctrine.PHP [options]
应该这样做.
doctrine-orm – Doctrine 2:写一个合适的Subselect
$qb = $this->entityManager->createqueryBuilder() ->select('w,se') ->from('Dashboard\Entity\Section','se') ->innerJoin('se.word','w') ->innerJoin('se.location','l'); $qb->add('where',$qb->expr()->andx( $qb->expr()->eq('l.ignored',$ignored),$qb->expr()->eq('l.id',$params['l_id']) ),true);
这条线以上的一切都很好
$totalQb = $this->entityManager->createqueryBuilder() ->select('COUNT(x.id)') ->from('Dashboard\Entity\Section','x');
上面的$totalQb本身运行良好.但是当我这样做的时候
以下,并尝试使用$qb作为$totalQb的子选择…
$dql = $qb->getDql(); $totalQb->add('where',$totalQb->expr()->exists( $dql )); $totalsql = $totalQb->getQuery(); $sql = $totalsql->getsql(); $total = $totalsql->getSingleScalarResult();
这是错误的
它指的是SubSelect’exists’语句.但是当我自己运行$dql时
它返回预期的结果
[Syntax Error] line 0,col 69: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM,got ','
在我的场景中进行子选择的正确方法是什么?
UPDATE
有人建议我添加$totalsql-> getDQL();这是该声明的输出:
SELECT COUNT(x.id) FROM Dashboard\Entity\Section x WHERE EXISTS( SELECT w,se FROM Dashboard\Entity\Section se INNER JOIN se.word w INNER JOIN se.location l AND (l.ignored = 0) AND (l.id = 2) GROUP BY w.id,l.id )
解决方法
doctrine2 – Doctrine 2 fetch =“EAGER”
/** * @ORM\OnetoOne(targetEntity="Application\Entity\Categorie",fetch="EAGER") * @ORM\JoinColumn(name="CAT_ID",referencedColumnName="CAT_ID") * @access protected * @var \Application\Entity\Categorie */ protected $CAT_ID;
当谈到第3级时,我遇到了这个问题.
实体“a”与实体“b”有关系.实体“b”与实体“c”有关系.在一个查询中选择实体“a”和实体“b”,并且在单个查询中将实体“c”与它们分开.我在它们之间的每个关系上都设置了fetch =“EAGER”.
不是Doctrine处理第三级中的fetch =“EAGER”或出错了什么?
<?PHP $query = $em->createquery("SELECT u FROM MyProject\User u"); $query->setFetchMode("MyProject\User","address",\Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER); $query->execute();
有关更多信息,请转到Doctrine docs.
今天的关于php – 自动为Doctrine生成get set方法和php自动生成文章的分享已经结束,谢谢您的关注,如果想了解更多关于delphi – 如何自动生成getter和setter方法、Doctrine CLI输出doctrine.php的内容、doctrine-orm – Doctrine 2:写一个合适的Subselect、doctrine2 – Doctrine 2 fetch =“EAGER”的相关知识,请在本站进行查询。
本文标签: