{"id":1210,"date":"2022-08-30T15:14:13","date_gmt":"2022-08-30T15:14:13","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/10\/doctrine-1-2-unknown-record-property-related-component-in-a-dql-with-only-1-table-envolved-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:14:13","modified_gmt":"2022-08-30T15:14:13","slug":"doctrine-1-2-unknown-record-property-related-component-in-a-dql-with-only-1-table-envolved-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/doctrine-1-2-unknown-record-property-related-component-in-a-dql-with-only-1-table-envolved-collection-of-common-programming-errors\/","title":{"rendered":"Doctrine 1.2 &#8211; Unknown record property \/ related component in a DQL with only 1 table envolved-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m trying to execute this DQL:<\/p>\n<pre><code>$q = Doctrine_Query::create()\n-&gt;select('*');\n-&gt;from('Clientes c');\n$retorno = $q-&gt;execute();\n<\/code><\/pre>\n<p>My BaseClientes.php:<\/p>\n<pre><code>\/\/ Connection Component Binding\nDoctrine_Manager::getInstance()-&gt;bindComponent('Clientes', 'padrao');\n\n\/**\n * BaseClientes\n * \n * This class has been auto-generated by the Doctrine ORM Framework\n * \n * @property integer $pk_clientes\n * @property string $txt_nome\n * @property timestamp $ts_cadastro\n * @property string $txt_diretorio\n * @property Doctrine_Collection $Upload\n * \n * @package    ##PACKAGE##\n * @subpackage ##SUBPACKAGE##\n * @author     ##NAME## \n * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $\n *\/\nabstract class BaseClientes extends Doctrine_Record\n{\n    public function setTableDefinition()\n    {\n        $this-&gt;setTableName('clientes');\n        $this-&gt;hasColumn('pk_clientes', 'integer', 4, array(\n             'type' =&gt; 'integer',\n             'length' =&gt; 4,\n             'fixed' =&gt; false,\n             'unsigned' =&gt; false,\n             'primary' =&gt; true,\n             'autoincrement' =&gt; true,\n             ));\n        $this-&gt;hasColumn('txt_nome', 'string', 255, array(\n             'type' =&gt; 'string',\n             'length' =&gt; 255,\n             'fixed' =&gt; false,\n             'unsigned' =&gt; false,\n             'primary' =&gt; false,\n             'notnull' =&gt; true,\n             'autoincrement' =&gt; false,\n             ));\n        $this-&gt;hasColumn('ts_cadastro', 'timestamp', null, array(\n             'type' =&gt; 'timestamp',\n             'fixed' =&gt; false,\n             'unsigned' =&gt; false,\n             'primary' =&gt; false,\n             'notnull' =&gt; true,\n             'autoincrement' =&gt; false,\n             ));\n        $this-&gt;hasColumn('txt_diretorio', 'string', 255, array(\n             'type' =&gt; 'string',\n             'length' =&gt; 255,\n             'fixed' =&gt; false,\n             'unsigned' =&gt; false,\n             'primary' =&gt; false,\n             'notnull' =&gt; true,\n             'autoincrement' =&gt; false,\n             ));\n    }\n\n    public function setUp()\n    {\n        parent::setUp();\n        $this-&gt;hasMany('Upload', array(\n             'local' =&gt; 'pk_clientes',\n             'foreign' =&gt; 'fk_clientes'));\n    }\n}\n<\/code><\/pre>\n<p>My table SQL:<\/p>\n<pre><code>CREATE TABLE  `organizer`.`clientes` (\n  `pk_clientes` int(11) NOT NULL AUTO_INCREMENT,\n  `txt_nome` varchar(255) NOT NULL,\n  `ts_cadastro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `txt_diretorio` varchar(255) NOT NULL,\n  PRIMARY KEY (`pk_clientes`)\n) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC\n<\/code><\/pre>\n<p>When I execute this DQL, it returns to me:<\/p>\n<pre><code>Fatal error: Uncaught exception 'Doctrine_Record_UnknownPropertyException' with message 'Unknown record property \/ related component \"clientes\" on \"Clientes\"' in \n\/var\/www\/organizer\/lib\/php\/doctrine\/lib\/Doctrine\/Record\/Filter\/Standard.php:55 Stack trace: #0 \/var\/www\/organizer\/lib\/php\/doctrine\/lib\/Doctrine\/Record.php(1382):\n Doctrine_Record_Filter_Standard-&gt;filterGet(Object(Clientes), 'clientes') #1 \/var\/www\/organizer\/lib\/php\/doctrine\/lib\/Doctrine\/Record.php(1337): Doctrine_Record-&gt;_get\n('clientes', true) #2 \/var\/www\/organizer\/lib\/php\/doctrine\/lib\/Doctrine\/Access.php(117): Doctrine_Record-&gt;get('clientes') #3 \/var\/www\/organizer\/lib\/php\/forger.php\n(387): Doctrine_Access-&gt;offsetGet('clientes') #4 \/var\/www\/organizer\/app\/clientes\/model.php(20): forger-&gt;Table(Array) #5 \/var\/www\/organizer\/app\/clientes\/controller.php\n(5): require_once('\/var\/www\/organi...') #6 \/var\/www\/organizer\/web\/index.php(9): require_once('\/var\/www\/organi...') #7 {main} thrown in \/var\/www\/organizer\/lib\/php\/\ndoctrine\/lib\/Doctrine\/Record\/Filter\/Standard.php on line 55\n<\/code><\/pre>\n<p>I really don&#8217;t know what is happening, I have this same situation in other file of my system and work.<\/p>\n<p>Please, someone help me&#8230;.<\/p>\n<p>OBS: Sorry my bad english, I&#8217;m Brazilian.<\/p>\n<ol>\n<li>\n<p>Thanks for the answers, but I&#8217;ve found the &#8220;error&#8221;&#8230;<\/p>\n<p>What I need is only recover the data in an array, so I searched in Google and found this:<\/p>\n<pre><code>$con = Doctrine_Manager::getInstance()-&gt;connection();\n$res = $con-&gt;execute(\"SELECT * FROM clientes;\", array(1));\n$retorno = $res-&gt;fetchAll();\n<\/code><\/pre>\n<p>And this solved my problem because I was trying to use the return of $q-&gt;execute() as an array&#8230;<\/p>\n<p>PS: Sorry for misspell xD&#8230;<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-10 00:10:02. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to execute this DQL: $q = Doctrine_Query::create() -&gt;select(&#8216;*&#8217;); -&gt;from(&#8216;Clientes c&#8217;); $retorno = $q-&gt;execute(); My BaseClientes.php: \/\/ Connection Component Binding Doctrine_Manager::getInstance()-&gt;bindComponent(&#8216;Clientes&#8217;, &#8216;padrao&#8217;); \/** * BaseClientes * * This class has been auto-generated by the Doctrine ORM Framework * * @property integer $pk_clientes * @property string $txt_nome * @property timestamp $ts_cadastro * @property string $txt_diretorio [&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],"tags":[],"class_list":["post-1210","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1210","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=1210"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1210\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}