{"id":31,"date":"2009-10-25T13:58:24","date_gmt":"2009-10-25T12:58:24","guid":{"rendered":"http:\/\/webpiraten.de\/?p=31"},"modified":"2009-10-28T22:54:56","modified_gmt":"2009-10-28T21:54:56","slug":"criteria-builder-propel-orm","status":"publish","type":"post","link":"https:\/\/webpiraten.de\/index.php\/php\/criteria-builder-propel-orm\/","title":{"rendered":"der Criteria Builder f\u00fcr Propel ORM Criterias"},"content":{"rendered":"<p><a href=\"http:\/\/propel.jondh.me.uk\/\" target=\"_blank\" title=\"der Criteria Builder f\u00fcr Propel ORM Criterias\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/webpiraten.de\/wp-content\/uploads\/2009\/10\/propel_criteria_builder-300x183.png\" alt=\"propel_criteria_builder\" title=\"propel_criteria_builder\" width=\"300\" height=\"183\" class=\"alignleft size-medium wp-image-33\" srcset=\"https:\/\/webpiraten.de\/wp-content\/uploads\/2009\/10\/propel_criteria_builder-300x183.png 300w, https:\/\/webpiraten.de\/wp-content\/uploads\/2009\/10\/propel_criteria_builder.png 698w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Die Propel ORM f\u00fcr PHP bedient sich einer eigenen Syntax (Criterias) um Queries zusammenzustellen. <\/p>\n<p>Hier gibt es einen Criteria Builder, den man mit Standard SQL f\u00fcttern kann.<\/p>\n<p>Der Criteria Builder konvertiert sodann das eingegebene SQL Statement in ein Propel Criteria. <\/p>\n<p>So wird aus diesem kleinen SQL Statement:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n\r\nSELECT user.*\r\nFROM user\r\nWHERE user.state = 100 \r\nAND (user.name = 'user' OR user.email = 'user@domain.tld')\r\n\r\n<\/pre>\n<p>diese Propel Criteria:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n$c = new Criteria();\r\n$crit0 = $c-&gt;getNewCriterion(UserPeer::STATE, 100);\r\n$crit1 = $c-&gt;getNewCriterion(UserPeer::NAME, 'user');\r\n$crit2 = $c-&gt;getNewCriterion(UserPeer::EMAIL, 'user@domain.tld');\r\n\r\n\/\/ Perform OR at level 1 ($crit1 $crit2 )\r\n$crit1-&gt;addOr($crit2);\r\n\r\n\/\/ Perform AND at level 0 ($crit0 $crit1 )\r\n$crit0-&gt;addAnd($crit1);\r\n\r\n\/\/ Remember to change the peer class here for the correct one in your model\r\n$c-&gt;add($crit0);\r\n$result = TablePeer::doSelect($c);\r\n\r\n\/\/ This loop will of course need to be edited to work\r\nforeach ($result as $obj)\r\n{\r\n\t\/\/$val = $obj-&gt;getValue();\r\n}\r\n\r\n<\/pre>\n<p>Einen Versuch ist es Wert.<\/p>\n<p><a href=\"http:\/\/propel.jondh.me.uk\/\" target=\"_blank\" title=\"der Criteria Builder f\u00fcr Propel ORM Criterias\">Hier gehts zum Propel ORM Criteria Builder<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Die Propel ORM f\u00fcr PHP bedient sich einer eigenen Syntax (Criterias) um Queries zusammenzustellen. Hier gibt es einen Criteria Builder, den man mit Standard SQL f\u00fcttern kann. Der Criteria Builder konvertiert sodann das eingegebene SQL Statement in ein Propel Criteria. So wird aus diesem kleinen SQL Statement: SELECT user.* FROM user WHERE user.state = 100 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,5,34],"tags":[40,37,634,13,36,39,38],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-mysql","category-php","category-propel-orm","tag-builder","tag-criteria","tag-mysql","tag-orm","tag-propel","tag-query","tag-sql"],"_links":{"self":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":18,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/posts\/31\/revisions\/166"}],"wp:attachment":[{"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webpiraten.de\/index.php\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}