Thursday, October 17, 2013

By posting your answer, you agree to the privacy policy and terms of service . Not the answer you


I have a record (entity) with this definition: abstract class BaseProductsXsell extends Doctrine_Record { public function setTableDefinition() { $this->setTableName('products_xsell'); portable food warmer $this->hasColumn('ID', 'integer', 4, array('type' => 'integer', 'length' => 4, 'primary' => true, 'autoincrement' => true)); $this->hasColumn('products_id', 'integer', 4, array('type' => 'integer', 'length' => 4, 'unsigned' => 1, 'default' => '1', 'notnull' => true)); // and so on... } }
In portable food warmer the MySQL database table the column name of "ID" is upper case, too. But when I try to fetch the column names after a query with this: $query = Doctrine_Query::create()->select('m.*')->from("ProductsXsell m"); $collection = $query->execute(); $columns = $collection->getTable()->getColumnNames(); print_r($columns);
This results in the following error: Fatal error: Uncaught exception 'Doctrine_Record_UnknownPropertyException' with message 'Unknown record property / related portable food warmer component "id" on "ProductsXsell"' in /opt/hocatec/bin/libs/Doctrine/Doctrine/Record/Filter/Standard.php:55 Stack trace: #0 /opt/hocatec/bin/libs/Doctrine/Doctrine/Record.php(1282): Doctrine_Record_Filter_Standard->filterGet(Object(ProductsXsell), 'id') #1 /opt/hocatec/bin/libs/Doctrine/Doctrine/Record.php(1240): Doctrine_Record->_get('id', portable food warmer true) #2 /opt/hocatec/bin/libs/Doctrine/Doctrine/Access.php(117): Doctrine_Record->get('id') #3 /opt/hocatec/bin/models/HocaSync.php(368): Doctrine_Access->offsetGet('id')
One problem with database compatibility is that many databases differ in their behavior of how the result set of a query is returned. MySQL leaves the field names unchanged, which means if you issue a query of the form "SELECT myField FROM ..." then the result set will contain the field myField.
Unfortunately, this is just the way MySQL and some other databases do it. Postgres for example returns all field names in lowercase whilst Oracle returns all field names in uppercase. So what? In what way does this influence me when using Doctrine? , you may ask. Fortunately, portable food warmer you don t have to bother about that issue at all.
Doctrine takes care of this problem transparently. That means if you define a derived Record class and define a field called myField you will always access it through $record->myField portable food warmer (or $record['myField'], whatever you prefer) no matter whether you re using MySQL or Postgres or Oracle etc.
Lone link is considered a poor answer since it is meaningless by itself and target resource is not guaranteed to be alive in the future. It would be preferable to include the essential parts of the answer here, and provide the link for reference (as I do when editing your answer). –  j0k Jan 19 at 11:08 1  
Thanks a lot! sorry, my mistake! but I think I was write the essential that was that the name of model must to be the same in his select sentence. Then I put the link for more reference –  Guido Jan 21 at 0:19  
Thanks for your answer, but it does not help me with my issue. I have defined the column ID in the model, but $collection->getTable()->getColumnNames() returns the column in lower case. Why does that happen? –  naitsirch Jan 22 at 9:59  
That occurs portable food warmer because that function calls the function getColumnName() foreach field of your table and that function returns this: strtolower($fieldname); You can see that in file named "Doctrine_Table" –  Guido Jan 22 at 17:42 Your Answer
By posting your answer, you agree to the privacy policy and terms of service . Not the answer you're looking for? Browse other questions portable food warmer tagged php mysql doctrine case-sensitive or ask your own question .
0 I can't load related records with Doctrine
Technology Life / Arts Culture / Recreation Science Other Stack Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters Game Development TeX - LaTeX Programmers Unix & Linux Ask Different (Apple) portable food warmer WordPress Answers Geographic Information Systems Electrical Engineering Android Enthusiasts Information Security Database Administrators Drupal portable food warmer Answers SharePoint User Experience Mathematica portable food warmer more (13) Photography Science Fiction & Fantasy Seasoned Advice (cooking) Home Improvement more (13) English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity Arqade (gaming) Bicycles portable food warmer Role-playing Games more (21) Mathematics Cross Validated (stats) Theoretical Computer Science Physics MathOverflow more (7) Stack Apps Meta Stack Overflow Area 51 Stack Overflow Careers
Stack Overflow works best with JavaScript enabled

No comments:

Post a Comment