Ok, I'm new to Cake, but not php. I don't know how to build my models
for easy creation of add, edit and delete actions.

I have three tables:

The records:

CREATE TABLE merits (
  meritId int(10) unsigned NOT NULL AUTO_INCREMENT,
  ar varchar(20) DEFAULT NULL,
  titel varchar(40) NOT NULL,
  plats varchar(40) DEFAULT NULL,
  stad varchar(40) DEFAULT NULL,
  beskrivning text,
  modifierad timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
  PRIMARY KEY (meritId)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1;

The categories:

CREATE TABLE kategoris (
  kategoriId int(10) unsigned NOT NULL AUTO_INCREMENT,
  kategoriNamn varchar(40) NOT NULL,
  PRIMARY KEY (kategoriId)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;

and the table to connect categories and the records:

CREATE TABLE cvs (
  kategoriId int(10) unsigned NOT NULL,
  meritId int(10) unsigned NOT NULL,
  PRIMARY KEY (kategoriId,meritId)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

For now I have managed to produce a index view with the following:

<?php
/**
 * @property Cvs $Cvs
 */

class CvsController extends AppController {

    var $name = 'Cvs';
    var $helpers = array('Minify', 'Mailto');

    function index() {

        $this->layout = 'cv';

        $this->set('utbildning', $this->Cv->query("SELECT merits.ar,
merits.titel, merits.plats, merits.stad, merits.beskrivning FROM
merits JOIN cvs ON merits.meritId = cvs.meritId JOIN kategoris ON
cvs.kategoriId = kategoris.kategoriId WHERE kategoris.kategoriNamn =
'Utbildning' ORDER BY merits.modifierad DESC;"));
    }
}
?>

A simple SQL-query, because I know how to work them.

Now, I don't know how to write the models, so i can add the other
actions, add, edit, delete. After some researches, I think it has
something to do with (hasOne, hasMany, belongsTo) but would certainly
need some help.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to