You are not logged in.
Happy Holidays everyone!
This short podcast covers how you can easily build a form using Zend's MVC model via Zend_Controller and using Doctrine for persistence.
You can download the source code or browse it online. Enjoy!
zend_controller, mvc, doctrine, relations, orm
Offline
Awesome stuff!
Finaly a example of how to use the stuff we've learned.:)
I see you don't use Zend Form. I guess its to make the example a little simpler. Is it much more difficult to use Zend Form than the way you did here? There must surely be some advantages with using Zend Form?
Offline
Hi,
I followed this tutorial but still i have some questions, here is my example:
Yaml:
Core_Model_Language:
connection: default
tableName: core_language
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
name:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
short:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
active:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
News_Model_Noticias:
local: id
foreign: lang_id
type: many
News_Model_Noticias:
connection: default
tableName: news_noticias
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
titulo:
type: string(250)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
small:
type: string(400)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
full:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
data_creation:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
published:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '0'
notnull: true
autoincrement: false
lang_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Core_Model_Language:
local: lang_id
foreign: id
type: one
Ok so i have this 2 tables (Models), i want to load all news and when presenting the list show the language name for that news item.
in my action i have:
public function indexAction()
{
$model = Doctrine::getTable('News_Model_Noticias');
$noticias = $model->findAll();
$this->view->noticias = $noticias;
}
Now if i vardump($this->noticias) on my view i get something like this:
array(1) {
[0] => array(7) {
["id"] => string(1) "4"
["titulo"] => string(5) "teste"
["small"] => string(24) "teste introdução noticia"
["full"] => string(18) "Montes de conteudo"
["data_creation"] => string(19) "0000-00-00 00:00:00"
["published"] => string(1) "0"
["lang_id"] => string(1) "1"
}
}
Is there an easy way i can get the relation data automaticly? something like:
array(1) {
[0] => array(7) {
["id"] => string(1) "4"
["titulo"] => string(5) "teste"
["small"] => string(24) "teste introdução noticia"
["full"] => string(18) "Montes de conteudo"
["data_creation"] => string(19) "0000-00-00 00:00:00"
["published"] => string(1) "0"
["language"] => array(4){
["id"] => string(1) "1"
["name"] => string(9) "Português"
["short"] => string(5) "pt_PT"
["active"] => string(1) "1"
}
}
}
If i vardump language model i get the news related to that language, but i wanna do it the other way around, fetch the news and have it grab the language object for each news item in an automated way, without having to write all the Joins by hand, since the languages table is related to pretty much all the other tables in my app.
Thanks in advance
Last edited by miguelp (2011-06-07 15:47:41)
Offline