{"id":1645,"date":"2022-08-30T15:18:15","date_gmt":"2022-08-30T15:18:15","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/problem-about-query-builder-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:15","modified_gmt":"2022-08-30T15:18:15","slug":"problem-about-query-builder-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-query-builder-collection-of-common-programming-errors\/","title":{"rendered":"problem about query-builder-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e2e69b14874d2e894a12bbe185382de0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nVictor Czechov<br \/>\nkohana kohana-3.2 query-builder<br \/>\nI need to INSERT a data to table, but before a query I must to know the MAX value from column position, than to INSERT a data WHERE my SELECTED before position+1. Is it possible with query builder?following my first comment I did query:$p = DB::select(array(DB::expr(&#8216;MAX(`position`)&#8217;, &#8216;p&#8217;)))-&gt;from(&#8216;supercategories&#8217;)-&gt;execute();echo $p;the error:ErrorException [ Notice ]: Undefined offset: 1MODPATH\\database\\classes\\kohana\\database.php [ 505 ]500 *\/ 501 public function quote_column<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8ec1c39676f6595378a80f31e935ad53?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBrent C<br \/>\nphp zend-framework doctrine2 service-layer query-builder<br \/>\nFor years now I&#8217;ve been reimplementing the same code over and over (with evolution) without finding some method of cleanly, and efficiently, abstracting it out.The pattern is a base &#8216;find[Type]s&#8217; method in my service layers which abstracts select query creation to a single point in the service, but supports the ability to quickly create easier to use proxy methods (see the example PostServivce::getPostById() method way below).Unfortunately, so far, I&#8217;ve been unable to satisfy these goals:Reduce<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3706347b4a7453ad5a549c7138fb4376?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndresch Serj<br \/>\nsymfony2 doctrine2 apc query-builder doctrine-query<br \/>\nI deleted a property (teaser) from an enitiy (sale). I used the CLi to update the database &amp; entites:$ php app\/console doctrine:schema:update &#8211;complete &#8211;force $ php app\/console doctrine:generate:entities Our &#8211;no-backup $ php app\/console doctrine:cache:clear-metadata $ php app\/console doctrine:cache:clear-resultAnd i cleared the cache:$ php app\/console cache:clear &#8211;no-optional-warmers &#8211;no-warmupNow i have a query created by query builder:$qb = $this-&gt;createQueryBuilder(&#8216;s&#8217;); $q = $qb-<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d29954ffe531db9e08c719e18a490a68?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKarem<br \/>\nphp kohana query-builder<br \/>\nlike you can do in a normal query:SELECT id, &#8216;Default&#8217; AS Type FROM &#8230;I would like to do that in Kohana, i tried:DB::select(&#8216;id&#8217;, array(&#8216;Default&#8217;, &#8216;Type&#8217;))-&gt;from(&#8216;&#8230;&#8217;)But it thinks that &#8220;Default&#8221; is a column so it returns with error unknown column Default.What can i do here to make a alias of my own defined column?<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:16:16. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Victor Czechov kohana kohana-3.2 query-builder I need to INSERT a data to table, but before a query I must to know the MAX value from column position, than to INSERT a data WHERE my SELECTED before position+1. Is it possible with query builder?following my first comment I did query:$p = DB::select(array(DB::expr(&#8216;MAX(`position`)&#8217;, &#8216;p&#8217;)))-&gt;from(&#8216;supercategories&#8217;)-&gt;execute();echo $p;the error:ErrorException [ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,8],"tags":[],"class_list":["post-1645","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-zend-framework"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1645"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1645\/revisions"}],"predecessor-version":[{"id":8975,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1645\/revisions\/8975"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}