Re: Model without table

2009-03-12 Thread brian

On Thu, Mar 12, 2009 at 3:21 AM, mscdex  wrote:
>
> On Mar 12, 2:21 am, kaushik  wrote:
>>  var $table = false;

Also, make the c in contact uppercase::

class Contact extends AppModel

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



Re: Model without table

2009-03-12 Thread mscdex

On Mar 12, 2:21 am, kaushik  wrote:
>  var $table = false;

As previously noted, it should be $useTable and not $table.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model without table

2009-03-11 Thread kaushik

As per your direction, i have used this code in model:

class contact extends AppModel
{
 var $name = 'Contact';
 var $table = false;
}

and this code in controller:
class ContactsController extends AppController
{
var $name = 'Contacts';

var $components = array('RequestHandler');
var $helpers = array('Html', 'Form', 'Javascript', 'Validation');
//var $scaffold;

function index()
{
  if (!empty($this->data['Contact']))
  {
//code for mailing
$msg = "Successful";
  }
}

}

Still it is giving this error:

"Missing Database Table

Error: Database table contacts for model Contact was not found."

What is wrong in my code?


On Mar 11, 11:05 pm, mscdex  wrote:
> On Mar 10, 7:32 am, Walther  wrote:
>
> > Just add in your model:
>
> > var $table = false;
>
> Close, it's actually $useTable.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model without table

2009-03-11 Thread Walther

Bugger,

I always get that one wrong, I obviously don't use it enough...

On Mar 11, 8:05 pm, mscdex  wrote:
> On Mar 10, 7:32 am, Walther  wrote:
>
> > Just add in your model:
>
> > var $table = false;
>
> Close, it's actually $useTable.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model without table

2009-03-11 Thread mscdex

On Mar 10, 7:32 am, Walther  wrote:
> Just add in your model:
>
> var $table = false;
>

Close, it's actually $useTable.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model without table

2009-03-11 Thread villas

Check out Jonathan Snook's article:
http://snook.ca/archives/cakephp/contact_form_cakephp/

On Mar 10, 8:10 am, kaushik  wrote:
> I am going to develop a section in a site, where there is no database
> operation. Only there will a form and a mail will fire on submit of
> the very form. How to design model for this section?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Model without table

2009-03-10 Thread Walther

Just add in your model:

var $table = false;

That will tell cake that there is no table associated with that model.

On Mar 10, 10:10 am, kaushik  wrote:
> I am going to develop a section in a site, where there is no database
> operation. Only there will a form and a mail will fire on submit of
> the very form. How to design model for this section?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Model without table

2009-03-10 Thread kaushik

I am going to develop a section in a site, where there is no database
operation. Only there will a form and a mail will fire on submit of
the very form. How to design model for this section?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: model without table: contact form (CAKE 1.2.0.54727alpha)

2007-07-23 Thread cakeFreak

by the way, for those that need a contact form these are my views:
---
views/contacts/index.ctp
---
Contatti:

create('Contact', array('url'=>'/contacts'));?>
input('nome', array('error' => array(
'required' => 'specifica il
tuo nome')
)
);

echo $form->input('cognome', array('error' => array(
'required' => 'specifica il
tuo cognome')
)
);

echo $form->input('e-mail', array('error' => array(
'required' => 'specifica la
tua e-mail',
'validEmail' => 'inserisci un
e-mail valida'
)
)
);
echo $form->input('oggetto', array('error' => array(
'required' => 'specifica l
\'oggetto')
)
);

echo $form->input('messaggio', array('error' => 
array('required' =>
'inserisci il messaggio'),
 'type'=>'textarea',
'cols'=>30));
?>



---
views/layouts/email/text/email.ctp
---
---
EMAIL FROM YOUR WEBSITE NAME HERE
---
FROM   : 

E-MAIL : 

SUBJECT: 

---

MESSAGE:

---




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



model without table: contact form (CAKE 1.2.0.54727alpha)

2007-07-23 Thread cakeFreak

Hey guys,

I'm in the case of a model without a table, and in particular a
contact form.
I'm using the last alpha cakePHP 1.2.0.54727alpha.

Despite using var $useTable = false; in my contact model I had to add
a loadInfo() method in the contact model.

my Contact Model looks as follows:

class Contact extends AppModel {

var $name = 'Contact';
var $useTable = false;
var $validate = array(
'nome' => array('required' => VALID_NOT_EMPTY),
'cognome' => array('required' => VALID_NOT_EMPTY),
'e-mail' => array('required' => VALID_NOT_EMPTY,
'validEmail'=>VALID_EMAIL),
'oggetto' => array('required' => VALID_NOT_EMPTY),
'messaggio' => array('required' =>
VALID_NOT_EMPTY),
);

   function loadInfo(){
if ($this->useTable === false)
{
$defaults = array(
'null' => false,
'default' => null,
'length' => null
);

   $campi = array('nome'=>'string',

  'cognome'=>'string',

  'e-mail'=>'string',

  'oggetto'=>'string',

  'messaggio'=>'text');

foreach($campi as $field => $type)
{
$fields[] = am(array('name'=>$field,
'type'=>$type), $defaults);
}

return new Set($fields);
}

return parent::loadInfo();
}


}


My contacts controller looks as follows:

class ContactsController extends AppController
{
var $name = "Contacts";
var $layout = 'single_news';
var $uses = 'Contact';
var $components = array('Email');


//-
function index(){

$this->set('title_for_layout', 'Contatti');

if(isset($this->data)) {

if($this->Contact->create($this->data) && $this->Contact-
>validates()){

//send e-mail
$this->_sendMail();
}
else{
$this->Session->setFlash('correggi gli errori
sottostanti');
//$this->redirect('/contacts');
}
}
}

function _sendMail() {

$senderEmail = $this->data['Contact']['e-mail'];

$this->Email->layout = 'email';
$this->Email->to = '[EMAIL PROTECTED]';
$this->Email->subject = $this->data['Contact']['oggetto'];
$this->Email->from = $senderEmail;
$this->Email->template = 'text';
//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'text';
//Set view variables as normal
$this->set('nome', ucfirst($this->data['Contact']['nome']));
$this->set('cognome', ucfirst($this->data['Contact']
['cognome']));
$this->set('email', $senderEmail);
$this->set('oggetto', $this->data['Contact']['oggetto']);
$this->set('messaggio', $this->data['Contact']['messaggio']);
//Do not pass any args to send()
if ( $this->Email->send() ) {
$this->Session->setFlash('La tua e-mail è stata
spedita con successo');
$this->redirect('/');
exit;
} else {
$this->Session->setFlash("Ci sono stati dei problemi
nell'inviare l'e-mail. Ti invitiamo a riprovare");
$this->redirect('/contacts/index/');
exit;
}

}

}


with PHP5 everything fine.

with PHP4 I get the following error:

Fatal error: Call to undefined function: set__() in /home/intellig/
cake_1.2.0.5427alpha/cake/libs/overloadable_php4.php on line 162

Anybody encountered the same problem?

Is there a better way to use models without DB tables?

Dan


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---