Kohana 3.3 ORM - Vistas de la base de datos

Is there a way to use the orm factory to pull from a view instead of a table? I was hoping that the syntax would be equivalent to pulling from a table:

$buyers = ORM::factory('vbuyer'); //where vbuyers is the name of the view

This results in the error : ErrorException [ Fatal Error ]: Class 'Model_Vbuyer' not found

Unfortunately that doesn't seem to work. Can I have the orm map a view to a model, or do I have to use the DB::select('*')->from('vbuyers') ¿Acercarse?

EDIT: The problem was actually that the filename of the vbuyer model was incorrect, it had an underscore v_buyer. Removed the underscore and it worked.

EDIT: To answer the original question - yes, you can use the ORM factory to generate models based on database views. The problem in this case was unrelated, see above.

preguntado el 05 de mayo de 13 a las 21:05

"that doesn't seem to work" --- doesn't work isn't a proper issue explanation -

@zerkms - updated the question with the error message thrown -

Have you created the model class? -

@zerkms - I did create the model class - I had previously had an underscore in the name of the view, and it didn't work. So thinking that the underscore was the problem i took it out from the view and model name, but forgot to take the underscore out of the model's filename. Are underscores not allowed in model names? Btw, it's working now that i renamed the file! -

el nombre del archivo debe ser classes/model/vbuyer.php -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.