Doctrine relationships - doctrine

I have two tables. A users table and a profile table. The profile table has a foreign key of users_id. The models for the tables are set up with one to one relationships. When I try and save some data I get this error:
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'users_id' cannot be null' in
If I just save data to the users table then I know that it is auto_incrementing and generating a new id value. However, for some reason when I try and link the tables together or call $users->id then it returns a value of NULL.
Here is my code:
$u = new Users();
// Users table.
$u->username = $username;
$u->password = $password;
$u->email = $email;
$u->groups_id = $group_id;
$u->ip_address = $ip_address;
$u->last_login = now();
$u->active = 1;
if ($this->store_salt)
{
$u->salt = $salt;
}
$u->save();
// Profile table.
$p = new Profile();
$p->first = $additional_data['first'];
$p->last = $additional_data['last'];
$p->role = $additional_data['role'];
$p->Users = $u;
$p->save(); return;
Here are the models:
/**
* BaseUsers
*
* This class has been auto-generated by the Doctrine ORM Framework
#property integer $id
#property string $username
#property string $password
#property string $ip_address
#property date $created_at
#property date $updated_at
#property string $salt
#property string $email
#property string $activation_code
#property string $forgotten_password_code
#property string $remember_code
#property integer $last_login
#property integer $active
#property integer $groups_id
#property Groups $Groups
#package ##PACKAGE##
#subpackage ##SUBPACKAGE##
#author ##NAME## <##EMAIL##>
#version SVN: $Id: Builder.php 6401 2009-09-24 16:12:04Z guilhermeblanco $
*/
abstract class BaseUsers extends Doctrine_Record
{
public function setTableDefinition()
{
$this->actAs("Timestampable");
$this->setTableName('users');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'length' => 4,
'unsigned' => 0,
'primary' => true,
'autoincrement' => true,
));
$this->hasColumn('username', 'string', 45, array(
'type' => 'string',
'length' => 45,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('password', 'string', 45, array(
'type' => 'string',
'length' => 45,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('ip_address', 'string', 16, array(
'type' => 'string',
'length' => 16,
'fixed' => true,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('created_at', 'date', null, array(
'type' => 'date',
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('updated_at', 'date', null, array(
'type' => 'date',
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('salt', 'string', 40, array(
'type' => 'string',
'length' => 40,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('email', 'string', 40, array(
'type' => 'string',
'length' => 40,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('activation_code', 'string', 40, array(
'type' => 'string',
'length' => 40,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('forgotten_password_code', 'string', 40, array(
'type' => 'string',
'length' => 40,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('remember_code', 'string', 40, array(
'type' => 'string',
'length' => 40,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('last_login', 'integer', 4, array(
'type' => 'integer',
'length' => 4,
'unsigned' => 1,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('active', 'integer', 1, array(
'type' => 'integer',
'length' => 1,
'unsigned' => 1,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('groups_id', 'integer', 4, array(
'type' => 'integer',
'length' => 4,
'unsigned' => 1,
'primary' => true,
'autoincrement' => false,
));
}
public function setUp()
{
parent::setUp();
$this->hasOne('Groups', array(
'local' => 'groups_id',
'foreign' => 'id'));
$this->hasOne('Profile', array(
'local' => 'id',
'foreign' => 'users_id'));
}
}
<?php
/**
* BaseProfile
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* #property integer $id
* #property string $role
* #property string $first
* #property string $last
* #property string $email
* #property string $phone_1
* #property string $phone_2
* #property string $address
* #property string $postcode
* #property date $created_at
* #property date $updated_at
* #property Doctrine_Collection $Member
* #property Doctrine_Collection $Post
* #property Doctrine_Collection $ThreadHasProfile
* #property Doctrine_Collection $UserSetting
*
* #package ##PACKAGE##
* #subpackage ##SUBPACKAGE##
* #author ##NAME## <##EMAIL##>
* #version SVN: $Id: Builder.php 6401 2009-09-24 16:12:04Z guilhermeblanco $
*/
abstract class BaseProfile extends Doctrine_Record
{
public function setTableDefinition()
{
$this->actAs("Timestampable");
$this->setTableName('profile');
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'length' => 4,
'unsigned' => 0,
'primary' => true,
'autoincrement' => true,
));
$this->hasColumn('users_id', 'integer', 4, array(
'type' => 'integer',
'length' => 4,
'unsigned' => 0,
'primary' => false,
'autoincrement' => false,
));
$this->hasColumn('role', 'string', null, array(
'type' => 'string',
'fixed' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('first', 'string', 45, array(
'type' => 'string',
'length' => 45,
'fixed' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('last', 'string', 45, array(
'type' => 'string',
'length' => 45,
'fixed' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('phone_1', 'string', 45, array(
'type' => 'string',
'length' => 45,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('phone_2', 'string', 45, array(
'type' => 'string',
'length' => 45,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('address', 'string', 200, array(
'type' => 'string',
'length' => 200,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('postcode', 'string', 10, array(
'type' => 'string',
'length' => 10,
'fixed' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
));
$this->hasColumn('created_at', 'date', null, array(
'type' => 'date',
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
$this->hasColumn('updated_at', 'date', null, array(
'type' => 'date',
'primary' => false,
'notnull' => true,
'autoincrement' => false,
));
}
public function setUp()
{
parent::setUp();
$this->hasMany('Member', array(
'local' => 'id',
'foreign' => 'profile_id'));
$this->hasMany('Post', array(
'local' => 'id',
'foreign' => 'profile_id'));
$this->hasMany('ThreadHasProfile', array(
'local' => 'id',
'foreign' => 'profile_id'));
$this->hasMany('UserSetting', array(
'local' => 'id',
'foreign' => 'profile_id'));
$this->hasOne('Users', array(
'local' => 'users_id',
'foreign' => 'id'));
}
}

There are a number of ways to skin this cat. I have created a simplified example based loosely on what I can gather from your question.
Firstly, here is the YAML that I use to generate for my one-to-one model classes:
Identity:
columns:
username: string(50)
password: string(50)
email: string(50)
Profile:
columns:
identity_id: integer(10)
firstname: string(50)
lastname: string(50)
relations:
Identity:
foreignType: one
Now in PHP I can create a new Identity (or User in your case) and add related Profile data by simply:
$identity = new Identity();
$identity->username = 'james';
$identity->password = 'secret';
$identity->email = 'james#bond.com';
//now adding the related data
$identity->Profile->firstname = 'james';
$identity->Profile->lastname = 'bond';
$identity->save();
Hopefully this example will help you a bit.
edit:
here are the generated classes from the YAML in case that also helps:
BaseIdentity.php
<?php
abstract class BaseIdentity extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('identity');
$this->hasColumn('username', 'string', 50, array(
'type' => 'string',
'length' => '50',
));
$this->hasColumn('password', 'string', 50, array(
'type' => 'string',
'length' => '50',
));
$this->hasColumn('email', 'string', 50, array(
'type' => 'string',
'length' => '50',
));
}
public function setUp()
{
parent::setUp();
$this->hasOne('Profile', array(
'local' => 'id',
'foreign' => 'identity_id'));
}
}
BaseProfile.php
<?php
abstract class BaseProfile extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('profile');
$this->hasColumn('identity_id', 'integer', 10, array(
'type' => 'integer',
'length' => '10',
));
$this->hasColumn('firstname', 'string', 50, array(
'type' => 'string',
'length' => '50',
));
$this->hasColumn('lastname', 'string', 50, array(
'type' => 'string',
'length' => '50',
));
}
public function setUp()
{
parent::setUp();
$this->hasOne('Identity', array(
'local' => 'identity_id',
'foreign' => 'id'));
}
}

Before $p->save();, have $p->users_id = $u->id.
Also, why are you calling the table Users (plural)? That's just going to make code very confusing.
Also again, if you have separate tables to hold different info about the user (a User and a user's Profile) because you saw it in sfGuardPlugin, PLEASE DO NOT DO THIS! It is a ridiculous idea that will only make you regret it later. I don't know what the Symfony/Doctrine team were drinking when they thought of that idea...

Related

Custom product attribute not showing in admin catalog section magento 2.1

I have added custom product attribute in Magento 2.1 and that product is showing in attribute section but couldn't be shown in magento catalog section where we have created products
Below are the code which I am using to create attribute.
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
/**
* Add attributes to the eav/attribute
*/
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'test_author',
[
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Test Author',
'input' => '',
'class' => '',
'source' => '',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0,
'searchable' => true,
'filterable' => true,
'comparable' => false,
'visible_on_front' => true,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => ''
]
);
You can try the following code -
/** #var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
/**
* Add attributes to the eav/attribute
*/
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'test_author',
[
'group' => 'General',
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Test Author',
'input' => 'textarea',
'class' => '',
'source' => '',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
]
);

Symfony 1.4 doctrine create table

Can someone show me an example on how to use the createTable in Doctrine?
For example, I'd like to create a table 'attachment' with the following columns:
'file_path' =>string
'message_id'=>integer
Thanks
Found it :
$this->createTable('attachment', array(
'id' =>
array(
'type' => 'integer',
'length' => 8,
'autoincrement' => true,
'primary' => true,
),
'file_path' =>
array(
'type' => 'string',
'notnull' => true,
'length' => 255,
),
'message_id' =>
array(
'type' => 'integer',
'notnull' => false,
'length' => 8,
),
'created_at' =>
array(
'notnull' => true,
'type' => 'timestamp',
'length' => 25,
),
'updated_at' =>
array(
'notnull' => true,
'type' => 'timestamp',
'length' => 25,
),
), array(
'indexes' =>
array(
),
'primary' =>
array(
0 => 'id',
),
'collate' => 'utf8_general_ci',
'charset' => 'utf8',
));

How set a default Value with EAV AddAttribute

I want to set up an new attribute-set to my products in magento. This attribute should be type of selection from some options.
$installer->addAttribute('catalog_product', 'reserve', array(
'backend_label' => 'Attribute Reserve',
'type' => 'varchar',
'input' => 'select',
#'backend' => 'eav/entity_attribute_source_boolean',
'frontend' => '',
'source' => '',
#'default' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false,
'option' => array(
'value' => array(
'optionone' => array( 'O' ),
'optiontwo' => array( 'P' ),
'optionthree' => array( 'Kein Angabe' ),
)
),
));
How can I set optionthree to default value?
Had the same problem. My solution:
$installer->addAttribute('catalog_product', 'reserve', array(
'backend_label' => 'Attribute Reserve',
'type' => 'int',
'input' => 'select',
#'backend' => 'eav/entity_attribute_source_boolean',
'frontend' => '',
'source' => 'eav/entity_attribute_source_table',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'visible_in_advanced_search' => false,
'option' => array(
'value' => array(
'optionone' => array( 'O' ),
'optiontwo' => array( 'P' ),
'optionthree' => array( 'Kein Angabe' ),
)
),
));
Notice the different type (int instead of varchar) and source (eav/entity_attribute_source_table). This is the way Magento represents typical select attributes. Now you can set the default value like this:
$model = Mage::getModel('eav/entity_attribute')
->load($installer->getAttributeId('catalog_product', 'reserve'));
$model
->setDefaultValue($model->getSource()->getOptionId('Keine Angabe'))
->save();
Please use this script:-
$installer->addAttribute('catalog_product', 'reserve', array(
'backend_label' => 'Attribute Reserve',
'type' => 'varchar',
'input' => 'select',
#'backend' => 'eav/entity_attribute_source_boolean',
'frontend' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'visible_in_advanced_search' => false,
'option' => array(
'value' => array(
'optionone' => array( 'O' ),
'optiontwo' => array( 'P' ),
'optionthree' => array( 'Kein Angabe' ),
)
),
/**
* This will set the default values,
* as "array" data type is being used to set proper default value
*/
'default' => array(
'optionthree'
),
));
Hope it helps.
Navigate to Catalog >Manage Attributes to create new attribute and manage attribue stes to create new attribute set.
Please check the screenshot

The problem of the relationship in Mysql, doctrine gets this error: Doctrine_Table_Exception: Unknown relation alias Model_Training

I have a problem with relationships in the Doctrine. Works on Mysql database. The problem occurs when downloading data using the relationship throws me this error: Doctrine_Table_Exception: Unknown relation alias Model_Training
Please help me get tired of it some days I sit on it and nothing came up, and google also did not find anything.
Here is the code that retrieves data:
$dataRows = Doctrine_Query::create()
->from('Model_Training a')->where('a.idTrainings = ?', $this->_getParam('id'))
->leftJoin('a.Model_TrainingBonuse ac')
->leftJoin('a.Model_Bonuse ad')
->fetchArray();
Schema.yml file with the formation of models for the Doctrine:
TrainingBonuse:
tableName: Trainings_has_Bonuses
columns:
Trainings_idTrainings:
type: integer(4)
notnull: true
autoincrement: true
Bonuses_idBonuses:
type: integer(4)
notnull: true
relations:
TrainingsIdTraining:
class: Training
local: Trainings_idTrainings
foreign: idTrainings
foreignAlias: Trainings_has_Bonuses
BonusesIdBonuse:
class: Bonuse
local: Bonuses_idBonuses
foreign: idBonuses
foreignAlias: Trainings_has_Bonuses
indexes:
fk_Trainings_has_Bonuses_Bonuses1:
fields: [Bonuses_idBonuses]
fk_Trainings_has_Bonuses_Trainings1:
fields: [Trainings_idTrainings]
options:
charset: utf8
collate: utf8_polish_ci
Bonuse:
tableName: Bonuses
columns:
idBonuses:
type: integer(4)
primary: true
notnull: true
autoincrement: true
name:
type: string(45)
title:
type: string(255)
description:
type: clob(65535)
file_url_full:
type: string(255)
file_type:
type: integer(1)
width_full:
type: integer(4)
height_full:
type: integer(4)
active:
type: integer(1)
default: 1
options:
charset: utf8
collate: utf8_polish_ci
Training:
tableName: Trainings
columns:
idTrainings:
type: integer(4)
primary: true
notnull: true
autoincrement: true
title:
type: string(255)
sub_title:
type: string(255)
up_body:
type: clob(65535)
training_body:
type: clob(65535)
question:
type: clob(65535)
opinion:
type: clob(65535)
bonuses:
type: integer(1)
notnull: true
default: 0
down_body:
type: clob(65535)
modyfication:
type: integer(1)
notnull: true
default: 0
active:
type: integer(1)
notnull: true
default: 1
options:
charset: utf8
collate: utf8_polish_ci
Models:
TRAINING
abstract class Model_Base_Training extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Trainings');
$this->hasColumn('idTrainings', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('sub_title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('up_body', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('training_body', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('question', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('opinion', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('bonuses', 'integer', 1, array(
'type' => 'integer',
'notnull' => true,
'default' => 0,
'length' => '1',
));
$this->hasColumn('down_body', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('modyfication', 'integer', 1, array(
'type' => 'integer',
'notnull' => true,
'default' => 0,
'length' => '1',
));
$this->hasColumn('active', 'integer', 1, array(
'type' => 'integer',
'notnull' => true,
'default' => 1,
'length' => '1',
));
$this->option('collate', 'utf8_polish_ci');
$this->option('charset', 'utf8');
$this->option('type', 'InnoDB');
}
public function setUp()
{
parent::setUp();
$this->hasMany('Model_UserTraining as Users_has_Trainings', array(
'local' => 'idTrainings',
'foreign' => 'Trainings_idTrainings'));
$this->hasMany('Model_TrainingBonuse as Trainings_has_Bonuses', array(
'local' => 'idTrainings',
'foreign' => 'Trainings_idTrainings'));
}
}
TRAINING_BONUSES
abstract class Model_Base_TrainingBonuse extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Trainings_has_Bonuses');
$this->hasColumn('Trainings_idTrainings', 'integer', 4, array(
'type' => 'integer',
'notnull' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('Bonuses_idBonuses', 'integer', 4, array(
'type' => 'integer',
'notnull' => true,
'length' => '4',
));
$this->index('fk_Trainings_has_Bonuses_Bonuses1', array(
'fields' =>
array(
0 => 'Bonuses_idBonuses',
),
));
$this->index('fk_Trainings_has_Bonuses_Trainings1', array(
'fields' =>
array(
0 => 'Trainings_idTrainings',
),
));
$this->option('collate', 'utf8_polish_ci');
$this->option('charset', 'utf8');
$this->option('type', 'InnoDB');
}
public function setUp()
{
parent::setUp();
$this->hasOne('Model_Training as TrainingsIdTraining', array(
'local' => 'Trainings_idTrainings',
'foreign' => 'idTrainings'));
$this->hasOne('Model_Bonuse as BonusesIdBonuse', array(
'local' => 'Bonuses_idBonuses',
'foreign' => 'idBonuses'));
}
}
BONUSES
abstract class Model_Base_Bonuse extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Bonuses');
$this->hasColumn('idBonuses', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('name', 'string', 45, array(
'type' => 'string',
'length' => '45',
));
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('description', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('file_url_full', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('file_type', 'integer', 1, array(
'type' => 'integer',
'length' => '1',
));
$this->hasColumn('width_full', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('height_full', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('active', 'integer', 1, array(
'type' => 'integer',
'default' => 1,
'length' => '1',
));
$this->option('collate', 'utf8_polish_ci');
$this->option('charset', 'utf8');
$this->option('type', 'InnoDB');
}
public function setUp()
{
parent::setUp();
$this->hasMany('Model_TrainingBonuse as Trainings_has_Bonuses', array(
'local' => 'idBonuses',
'foreign' => 'Bonuses_idBonuses'));
}
}
There's no "Model_Training" table definition in your schema.yml file...theres "Training" though... If there's no "alias class" or "foreign alias" element specified in your schema.yml, table definition's name is used. So instead of "Model_Training" use "Training" (this applies to "Model_Bonuses" and others too).

Execution of subquery within table class gives class not found [doctrine]

In table class Ouders I do the following query:
$q = $this->createQuery('o')
->where('o.ouderid IN (SELECT DISTINCT k.parentid FROM Kinderen k WHERE k.schoolid = ?)', $schoolcode)
->orderBy('o.achternaam');
As you can see it has a subquery to the table class Kinderen.
Why does it give the error?:
An error occurred
Application error
Exception information:
Message: Couldn't find class Kinderen
Stack trace:
#0 /var/www/bredeschool/app/library/Doctrine/Table.php(256): Doctrine_Table->initDefinition()
#1 /var/www/bredeschool/app/library/Doctrine/Connection.php(1126): Doctrine_Table->__construct('Kinderen', Object(Doctrine_Connection_Mysql), true)
#2 /var/www/bredeschool/app/library/Doctrine/Query.php(1934): Doctrine_Connection->getTable('Kinderen')
#3 /var/www/bredeschool/app/library/Doctrine/Query.php(1732): Doctrine_Query->loadRoot('Kinderen', 'k')
#4 /var/www/bredeschool/app/library/Doctrine/Query/From.php(88): Doctrine_Query->load('Kinderen k')
#5 /var/www/bredeschool/app/library/Doctrine/Query/Abstract.php(2077): Doctrine_Query_From->parse('Kinderen k')
#6 /var/www/bredeschool/app/library/Doctrine/Query.php(1160): Doctrine_Query_Abstract->_processDqlQueryPart('from', Array)
#7 /var/www/bredeschool/app/library/Doctrine/Query.php(1126): Doctrine_Query->buildSqlQuery(true)
#8 /var/www/bredeschool/app/library/Doctrine/Query.php(843): Doctrine_Query->getSqlQuery()
#9 /var/www/bredeschool/app/library/Doctrine/Query.php(813): Doctrine_Query->parseSubquery('(SELECT DISTINC...')
#10 /var/www/bredeschool/app/library/Doctrine/Query.php(697): Doctrine_Query->parseFunctionExpression('(SELECT DISTINC...')
#11 /var/www/bredeschool/app/library/Doctrine/Query/Where.php(121): Doctrine_Query->parseClause('(SELECT DISTINC...')
#12 /var/www/bredeschool/app/library/Doctrine/Query/Where.php(81): Doctrine_Query_Where->_buildSql('o.ouderid', 'IN', '(SELECT DISTINC...')
#13 /var/www/bredeschool/app/library/Doctrine/Query/Condition.php(92): Doctrine_Query_Where->load('o.ouderid IN (S...')
#14 /var/www/bredeschool/app/library/Doctrine/Query/Abstract.php(2077): Doctrine_Query_Condition->parse('o.ouderid IN (S...')
#15 /var/www/bredeschool/app/library/Doctrine/Query.php(1160): Doctrine_Query_Abstract->_processDqlQueryPart('where', Array)
#16 /var/www/bredeschool/app/library/Doctrine/Query.php(1126): Doctrine_Query->buildSqlQuery(true)
#17 /var/www/bredeschool/app/library/Doctrine/Query/Abstract.php(958): Doctrine_Query->getSqlQuery(Array)
#18 /var/www/bredeschool/app/library/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
#19 /var/www/bredeschool/app/application/models/OudersTable.php(34): Doctrine_Query_Abstract->execute()
#20 /var/www/bredeschool/app/application/controllers/OudersController.php(44): Model_OudersTable->getView('111')
#21 /var/www/bredeschool/app/library/Zend/Controller/Action.php(513): OudersController->listAction()
#22 /var/www/bredeschool/app/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('listAction')
#23 /var/www/bredeschool/app/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#24 /var/www/bredeschool/app/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#25 /var/www/bredeschool/app/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#26 /var/www/bredeschool/bredeschoolzuidoost.nl/app/index.php(28): Zend_Application->run()
#27 {main}
Request Parameters:
array (
'controller' => 'ouders',
'action' => 'list',
'module' => 'default',
)
Kinderen model
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('Model_Kinderen', 'doctrine');
/**
* Model_Base_Kinderen
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* #property integer $kindid
* #property integer $parentid
* #property string $naamouder
* #property string $naambov1
* #property string $telefoonbov1
* #property string $relatiebov1
* #property string $naambov2
* #property string $telefoonbov2
* #property string $relatiebov2
* #property string $voornaam
* #property string $tussenvoegsel
* #property string $achternaam
* #property date $geboortedatum
* #property string $jomei
* #property integer $schoolid
* #property string $jufmeester
* #property integer $groep
* #property string $bijzonderheden
* #property string $zelfstandigheid
* #property string $opvang
* #property string $dagvdweek
* #property string $overig
* #property string $bso
* #property string $zwemdiploma
* #property timestamp $aanmaakdatum
* #property string $aanmeldwijze
*
* #package ##PACKAGE##
* #subpackage ##SUBPACKAGE##
* #author ##NAME## <##EMAIL##>
* #version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class Model_Base_Kinderen extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('kinderen');
$this->hasColumn('kindid', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('parentid', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '4',
));
$this->hasColumn('naamouder', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('naambov1', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('telefoonbov1', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('relatiebov1', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('naambov2', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('telefoonbov2', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('relatiebov2', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('voornaam', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('tussenvoegsel', 'string', 50, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '50',
));
$this->hasColumn('achternaam', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('geboortedatum', 'date', 25, array(
'type' => 'date',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '25',
));
$this->hasColumn('jomei', 'string', 10, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '10',
));
$this->hasColumn('schoolid', 'integer', 2, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '2',
));
$this->hasColumn('jufmeester', 'string', 50, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '50',
));
$this->hasColumn('groep', 'integer', 1, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '1',
));
$this->hasColumn('bijzonderheden', 'string', 500, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '500',
));
$this->hasColumn('zelfstandigheid', 'string', 75, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '75',
));
$this->hasColumn('opvang', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('dagvdweek', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('overig', 'string', 400, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '400',
));
$this->hasColumn('bso', 'string', 50, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '50',
));
$this->hasColumn('zwemdiploma', 'string', 5, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '5',
));
$this->hasColumn('aanmaakdatum', 'timestamp', 25, array(
'type' => 'timestamp',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '25',
));
$this->hasColumn('aanmeldwijze', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '20',
));
}
public function setUp()
{
parent::setUp();
$timestampable0 = new Doctrine_Template_Timestampable(array(
'created' =>
array(
'name' => 'aanmaakdatum',
),
'updated' =>
array(
'disabled' => true,
),
));
$this->actAs($timestampable0);
}
}
Ouders model
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('Model_Ouders', 'doctrine');
/**
* Model_Base_Ouders
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* #property integer $ouderid
* #property integer $userid
* #property integer $clusterid
* #property string $voornaam
* #property string $tussenvoegsel
* #property string $achternaam
* #property string $straat
* #property string $huisnummer
* #property string $postcode
* #property string $woonplaats
* #property string $telefoonvast
* #property string $telefoonmobiel
* #property string $telefoonwerk
* #property string $emailadres
* #property string $stadspas
* #property integer $inkomensniveau
* #property timestamp $aanmaakdatum
*
* #package ##PACKAGE##
* #subpackage ##SUBPACKAGE##
* #author ##NAME## <##EMAIL##>
* #version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
*/
abstract class Model_Base_Ouders extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('ouders');
$this->hasColumn('ouderid', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('userid', 'integer', 2, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '2',
));
$this->hasColumn('clusterid', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '4',
));
$this->hasColumn('voornaam', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('tussenvoegsel', 'string', 50, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '50',
));
$this->hasColumn('achternaam', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('straat', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('huisnummer', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('postcode', 'string', 7, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '7',
));
$this->hasColumn('woonplaats', 'string', 100, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '100',
));
$this->hasColumn('telefoonvast', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('telefoonmobiel', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('telefoonwerk', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('stadspas', 'string', 20, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '20',
));
$this->hasColumn('inkomensniveau', 'integer', 1, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '1',
));
$this->hasColumn('aanmaakdatum', 'timestamp', 25, array(
'type' => 'timestamp',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '25',
));
}
public function setUp()
{
parent::setUp();
$timestampable0 = new Doctrine_Template_Timestampable(array(
'created' =>
array(
'name' => 'aanmaakdatum',
),
'updated' =>
array(
'disabled' => true,
),
));
$this->actAs($timestampable0);
}
}
Thanks a lot!
Chris
As far as I noticed your model classes are named Model_Kinderen and Model_Ouders but in DQL subquery you use Kinderen. Kinderen is your database table name.
DQL is not SQL. You should work with objects and not tables.
I'm sorry if I missed something. I'm not really familiar with Zend as a framework.

Resources