2

Anybody have idea about how to handle database view in PHP symfony1.4?

I have created a view 'ABC' manually in DB. Now, I want to select records from that view 'ABC' with adding where clause in query. If possible give example.

EDIT:

My schema is:

Product:
  columns:
    name:             { type: string(127), notnull: true }
    launch_date:      { type: date }
    price:            { type: integer }
    status_id:        { type: integer }

ProductLocation :
    product_id:       { type: integer }
    name:             { type: string(50) }
    launch_date:      { type: date }
  relations:
    Product:          {onDelete: RESTRICT, local: product_id, foreign: id, foreignAlias: "Products" } 

I want to create view for union of two tables. Thanks

0

2 Answers 2

2

You just need to define the view in your schema.yml with every thing like the one you created manually in your DB.

Then rebuild your schema (php symfony doctrine:build --model) and you will be able to access your view using Doctrine function. But you will get error if you try to create anything in this view, which is normal.

I can provide example if you provide more information about your view (fields, name, etc ..)

Edit:

By the way, did you seach on Google?

They both explain how to create view from a query and then use it to browse result but I'm almost sure that you can use the method I described above.

Edit 2:

Defined a view in the schema is exactly the same as defined a real table, try with something like that (adjust field inside):

Product_ProductLocation:
  columns:
    name:             { type: string(127), notnull: true }
    launch_date:      { type: date }
    price:            { type: integer }
    status_id:        { type: integer }
    product_id:       { type: integer }
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks guys... @j0k: I have two tables: Product(name,launch_date,price,status_id) & ProductLocation(product_id,name,launch_date) My View will be union of two tables. Please provide example. Thank you.
@monishk can you update your question with the structure of your view?
My View Structure is Product_ProductLocation(name,launch_date,price,status_id,product_id,name,launch_date) that is union of two tables listed above.
But can I have the schema? I mean, I also need the type of each field. Update your main question with these information.
if you are not clear my question then please show me the sample for how to define view in schema....thanks...:)
0

This is possible in Symfony. I did not try it but I putting a link for you reference. http://trac.propelorm.org/wiki/Documentation/1.3/FAQ#DoesPropelsupportViews. Good luck

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.