doctrine

doctrine findby relation

I'm having trouble selecting a subset of data with doctrine. I have 3 tables Location Contact Contact_location The contact and location tables hold a name and an id the other table holds only ID's. For instance: Location loc_id: 1 name: detroit Contact contact_id: 1 name: Mike Contact_location loc_id: 1 contact_id: 1 In doctr...

pass data from the action layer to the model

I have an DQL query in LocationTable.class.php For this query i need an id which is passed to the action via the URL ?id=2 In the action i can access this with $request->getParamater('id'), but how can i also make this available to the model where my query resides? i need it for a where clause. ...

Doctrine enum type by value

I have a column in a table defined as following in my yaml file: myTable: columns: value: type: enum length: 2 values: ['yes', 'no'] In the code I am trying to insert data into this table but I can't figure out a way to insert the data using the enum text value (ie. 'yes' or 'no'). What I was trying was is som...

Symfony/Doctrine/SfGuardPlugin: Redirect to requested page (route), and not referrer

I want to be able to take the user to the requested page after login, but this does not happen with sfGuard. ** My Register action requires SignIn ;) ** On the listing page [http://cim/frontend_dev.php/] -> user clicks the 'Register' link [@register = register/index] -> user is taken to 'Signin' page provided by sfGuard -> after sign-in...

How to solve 'Badly constructed integrity constraints' in doctrine

When I execute the command './doctrine build-all-reload' It comes out the following output: build-all-reload - Are you sure you wish to drop your databases? (y/n) y build-all-reload - Successfully dropped database for connection named 'doctrine' build-all-reload - Generated models successfully from YAML schema build...

Do I need to wrap strings with '' when using Doctrine update set method?

Hi, I am using Doctrine Update query as follow. $oQuery = Doctrine_Query::create() ->update("Model") ->set("field",$value); the problem is that if $value is string, I have to ->set("field","'".$value."'"); if it normal? Why can't doctrine do it itself? am I missing something? ...

Does Doctrine 1.2 support importing indexes with Doctrine_Core::generateModelsFromDb function?

Does Doctrine 1.2 support importing indexes with Doctrine_Core::generateModelsFromDb() function? I need to make a migration between 2 database connections, one of them having unique index on 2 fields and one doesn't. And my migration is empty. It looks like Doctrine doesn't support indexes when importing from databae, other than those t...

Doctrine/symfony: getSqlQuery() output in phpMyAdmin/SQL tab

Hi, i have created this query that works OK: $q1 = Doctrine_Query::create() ->from('Usuario u') ->leftJoin('u.AmigoUsuario a ON u.id = a.user2_id OR u.id = a.user1_id') ->where("a.user2_id = ? OR a.user1_id = ?", array($id,$id)) ->andWhere("u.id <> ?", $id) ->andWhere("a.estado LIKE ?", 1); echo $q1->getSqlQue...

"SQLSTATE[23000]: Integrity constraint violation" in Doctrine

Hi, i do get an Integrity constraint violation for Doctrine though i really can't see why. Schema.yml User: columns: id: type: integer primary: true autoincrement: true username: type: varchar(64) notnull: true email: type: varchar(128) notnull: true password: type: var...

Symfony / Doctrine - How to filter form field by property in related model

I have a UserForm class which has a select list populated from a related model (specified by a foreign relationship in the yml) like so: $this->setWidget('report_id', new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Report')))); I'd like to filter the Report objects that come from this relation by one of the...

how to define current timestamp in yaml with doctrine

I tried the following yaml code: columns: created_time: type: timestamp notnull: true default: default CURRENT_TIMESTAMP In the outputted sql statement, the field is treated as datetime instead of timestamp, which I cannot define the current timestamp in it... If I insist to use timestamp to store current time, how to...

doctrine default values and relations

In mysql I can set default value for column like this: ALTER TABLE <Table> CHANGE <Column> DEFAULT <NEW_DEFAULT_VALUE> I can retrieve default value: SELECT DEFAULT(<Column>) FROM <Table> LIMIT 1 Is it possible to achieve this concept with Doctrine? What I actually need is such methods in my table class: class UserTable extend Doc...

zend-framework doctrine, and mvc pattern: what should connect data between models and forms?

I am learning Zend Framework and Doctrine. I am wondering what is the best practice to connect forms to models and vice versa. In some cases it is handy to load data from model in form class. Lets say a very unique class which use many models. In other cases it is convenient to have methods in model class which prepares data for forms...

Symfony fk issue on insertion

Hi, I posted a similar problem but it could not be resolved. I create a relational database of users and groups but for some reason I cannot insert test data with fixtures properly. Here is a sample of the schema: User: actAs: { Timestampable: ~ } columns: name: { type: string(255), notnull: true } email: { type: string(255...

generateUrl problem

I am trying to generate a url but I keep getting a strange warning even though it works. I am making an api xml page and I use the following call in the controller: public function executeList(sfWebRequest $request) { $this->users = array(); foreach($this->getRoute()->getObjects() as $user) { $this->users[$this->gene...

Defining table partitions via Doctrine Schema.yml

Is there a way to configure partitions thru Doctrine YML? Just like we define indexes, is there a syntax? If not, can raw SQL be added to the set-up function? Thanks ...

Doctrine: how to create a query using "LIKE REPLACE" ?

Hi, this SQL clause is working OK: SELECT * FROM `sf_guard_user` WHERE nombre_apellidos LIKE REPLACE('Mar Sanz',' ','%') Now I'm trying to write this query for Doctrine. I have tried this: $query->andWhere(sprintf('%s.%s LIKE REPLACE (?," ","%")', $query->getRootAlias(), $fieldName), 'Mar Sa...

Symfony models with foreign keys

So I have 2 models. Users and Groups. Each group has a user as the creator and a group has many users. The FK of these tables are set up correctly, but I was wondering if there was an easier way to get all related FK objects from other objects. For example, with a group object, is there a built in method to get the user object of the cre...

symfony restful api!

SO I am trying to make a restful api system with symfony and I am a little confused about something. So every different route gets sent to a different action method to be handled, however, many different actions display the same sort of data (list of users or a list of groups). I don't want to have to have redundant templates just becaus...

Using Doctrine to abstract CRUD operations

This has bothered me for quite a while, but now it is necessity that I find the answer. We are working on quite a large project using CodeIgniter plus Doctrine. Our application has a front end and also an admin area for the company to check/change/delete data. When we designed the front end, we simply consumed most of the Doctrine cod...