Re: Controllers Controller?

2011-10-08 Thread SyNeto
I decided to make a model named site and link users to thar model,
users have some links to other models like news and post, it's this a
betther aproach?

On 8 oct, 19:48, andrewperk  wrote:
> If your model has an association with the other model that you want to
> retrieve from, each time you do a find it will also retrieve any
> associated data as well. You can read about it here:
>
> http://book.cakephp.org/view/1039/Associations-Linking-Models-Together
>
> You can also use App::import. For instance if you wanted to import a
> User model so you could use it in a Tasks controller:
>
> App::import('Model', 'User');
> $userModel= new User();
> $userModel->find()
>
> ClassRegistry::init works as well.
>
> On Oct 7, 12:53 am, SyNeto  wrote:
>
>
>
>
>
>
>
> > Hi, im pretty new in cakephp, so feel free to correct me,
>
> > I have read the phpcake blog tutorial, and i have some noobs questions
> > about controllers.
>
> > if i need a view to display information from more than one model, how
> > can i achive this task?
>
> > I have already read some information about elements in views and some
> > information about the ClassRegistry::init, but i dont know if i am in
> > the rigth path.
>
> > tanks.
>
> > Ernesto Jiménez Villseñor.
>
> > PS. sorry about my english.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Problem with Controllers (Missing Controller)

2011-10-08 Thread Victor Forato
Thanks very much! My problem was completely resolved!

Now I can continue with my project! I was expecting problem with
configuration, apache or framework, but it was if the first line in the
code.

Thanks again,

Victor.

2011/10/9 Ryan Schmidt 

>
> On Oct 8, 2011, at 16:32, Victor Forato wrote:
>
> > I took a look in others posts, but I couldn't resolve my problem.
> > I'm trying acess the action register(http://localhost/cake/users/
> > register),but the cake show me this message:
> >
> > Error: UsersController could not be found.
> > Error: Create the class UsersController below in file: app\controllers
> > \users_controller.php
> >  > class UsersController extends AppController {
> >
> >   var $name = 'Users';
> > }
> > ?>
> >
> > ==>>There're my files:
> >
> > Directory:  app\controllers
> > File: users_controller.php
> > Code:
> > 
> > class UsersController extends AppController{
> >
>
> The opening PHP tag should be "".
>
>
> > Directory:  app\models
> > File: user.php
> > Code:
> > 
> > class User extends AppModel{
> >
>
> The opening PHP tag should be "".
>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Problem with Controllers (Missing Controller)

2011-10-08 Thread Ryan Schmidt

On Oct 8, 2011, at 16:32, Victor Forato wrote:

> I took a look in others posts, but I couldn't resolve my problem.
> I'm trying acess the action register(http://localhost/cake/users/
> register),but the cake show me this message:
> 
> Error: UsersController could not be found.
> Error: Create the class UsersController below in file: app\controllers
> \users_controller.php
>  class UsersController extends AppController {
> 
>   var $name = 'Users';
> }
> ?>
> 
> ==>>There're my files:
> 
> Directory:  app\controllers
> File: users_controller.php
> Code:
> 
> class UsersController extends AppController{
> 

The opening PHP tag should be "".


> Directory:  app\models
> File: user.php
> Code:
> 
> class User extends AppModel{
> 

The opening PHP tag should be "".

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: assertTags method interprets line breaks in my views and breaks test

2011-10-08 Thread andrewperk
I figured it out. It was because I had it indented inside of a php
block foreach loop. If I keep it on the same level as the php loop
code thats around it, the tests work fine.

Here's what I originally had that was causing the error:



User 1



This is how it should be, no indentation inside the php loop:



User 1



On Oct 7, 10:24 pm, andrewperk  wrote:
> How can I test my view's html that have formatting(line breaks,
> indenting) using assertTags? Here's the problem I'm running to:
>
> When I create html like this inside one of my views:
>
> 
>     User 1
> 
>
> And then run the assertTags method like so:
>
> $this->assertTags($result, array(
>                         'p'=>array(),
>                         'a'=>array('href'=>'index'),
>                         'User 1',
>                         '/a',
>                         '/p'
>                 ));
>
> This will fail because of the line breaks in the html. If I change my
> html to have zero linebreaks, all on one line:
>
> User 1
>
> It passes just fine.
>
> Do I need to somehow include these line breaks in my assertion? I
> don't know how to do this.
>
> Thanks for any help.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Controllers Controller?

2011-10-08 Thread andrewperk
If your model has an association with the other model that you want to
retrieve from, each time you do a find it will also retrieve any
associated data as well. You can read about it here:

http://book.cakephp.org/view/1039/Associations-Linking-Models-Together

You can also use App::import. For instance if you wanted to import a
User model so you could use it in a Tasks controller:

App::import('Model', 'User');
$userModel= new User();
$userModel->find()

ClassRegistry::init works as well.

On Oct 7, 12:53 am, SyNeto  wrote:
> Hi, im pretty new in cakephp, so feel free to correct me,
>
> I have read the phpcake blog tutorial, and i have some noobs questions
> about controllers.
>
> if i need a view to display information from more than one model, how
> can i achive this task?
>
> I have already read some information about elements in views and some
> information about the ClassRegistry::init, but i dont know if i am in
> the rigth path.
>
> tanks.
>
> Ernesto Jiménez Villseñor.
>
> PS. sorry about my english.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: Cakephp 1.3 not logging when debug set to 1 or 2

2011-10-08 Thread skyhigh
Did anyone find a solution to this issue?  I am having exactly the same 
problem. 

Calls to: 
   $this->log('test message', 'mylogfile'); 
will not log the message unless in the config/core.php file I set it to 
Configure:write('debug', 0); 

If the debug level is set to some other value such as 2 then nothing gets 
logged to the log file. 

I have looked at the previous answers posted here but they do not resolve 
this problem. 

1) It is not a Linux rights issue since CachePHP does successfully write to 
the log file if I set the debug level to 0.  It clearly has permission to 
write to the file. 

2) It is not a file name problem because of a conflict with CakePHP' debug 
mode usage of the same log file.  I have tested using several different file 
names such as 'mylogfile' and also using my name for the log file name and 
it consistently fails to write to the log file unless I set the debug level 
to 0. 

I am testing on a Linux server running Ubuntu 10.04

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Problem with Controllers (Missing Controller)

2011-10-08 Thread Victor Forato
I took a look in others posts, but I couldn't resolve my problem.
I'm trying acess the action register(http://localhost/cake/users/
register),but the cake show me this message:

Error: UsersController could not be found.
Error: Create the class UsersController below in file: app\controllers
\users_controller.php


==>>There're my files:

Directory:  app\controllers
File: users_controller.php
Code:

class UsersController extends AppController{

var $name = 'Users';

function register(){
if(!empty($this->params['form'])){
if($this->User->save($this->params['form'])){
$this->flash('Your registration information was 
accepted.',
'/users/register');
}else{
$this->flash('There was a problem with your 
registration.',
'users/register');
}
}

}
}
?>

Directory:  app\models
File: user.php
Code:

class User extends AppModel{

var $name = 'User';
}
?>

Directory:  app\views\users
File: register.ctp
Code: Code view


I'm using easyphp and putting myapplication in "C:\Program Files
(x86)\EasyPHP-5.3.8.1\www\cake".
I really want learn more about CakePHP but i cannot continue with this
problem. Any Ideia?

Thanks for attention, Victor.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: use alternative view folder?

2011-10-08 Thread sarahk
FWIW I, too, have a huge application driving 20 subdomains. The "owners" of
some of the subdomains need their own "skins" so I've been looking through
this.

My possible solution is to use bootstrap.

1. Add code to bootstrap to extend add 2 paths to  $viewPaths[]. (1) The
relevant subdomains path and (2) the default path
2. Rename views to "themes"
3. Create folders as required for each subdomain

This way render will look for the template in the normal location: always
fail
then it will look for the template in the error folder: always fail
look for it in the subdomain folder: if success, it will use this 
else look for it in themes path: always success

I'm using cake 1.1 but from the discussion above it doesn't look like this
has changed and it means I don't have to change core files.

--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/use-alternative-view-folder-tp3404605p4881443.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


hasAndBelongsToMany does not work

2011-10-08 Thread khalili merouane
Hello,

I have two tables categories and products when I try to view a
category, I just have the information in the category without
products.

When I check the applications running I see that selects the products
but does not display

I have the join table categories_products
and that the table queries


(default) 6 queries took 14 ms
Nr  Query   Error   AffectedNum. rows   Took (ms)
1   SHOW FULL COLUMNS FROM `products`19 19  6
2   SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE
COLLATION_NAME= 'utf8_general_ci';   1  1   1
3   SHOW FULL COLUMNS FROM `categories`  9  9   3
4   SHOW FULL COLUMNS FROM `categories_products` 5  5   2
5   SELECT `Product`.`id`, `Product`.`name`, `Product`.`slug`,
`Product`.`small_price`, `Product`.`medium_price`,
`Product`.`large_price`, `Product`.`discount_percentage`,
`Product`.`small_image_url`, `Product`.`large_image_url`,
`Product`.`description`, `Product`.`extended_description`,
`Product`.`additional_description`, `Product`.`active_for_home_page`,
`Product`.`position_home_page`, `Product`.`active_small_price`,
`Product`.`active_medium_price`, `Product`.`active_large_price`,
`Product`.`active`, `Product`.`gift_id` FROM `products` AS `Product`
WHERE `Product`.`id` = 20 LIMIT 11  1   1
6   SELECT `Category`.`id`, `Category`.`name`, `Category`.`slug`,
`Category`.`description`, `Category`.`description_is_image`,
`Category`.`image_url`, `Category`.`type`, `Category`.`popularity`,
`Category`.`active`, `AppModel`.`id`, `AppModel`.`category_id`,
`AppModel`.`product_id`, `AppModel`.`position`,
`AppModel`.`popularity` FROM `categories` AS `Category` JOIN
`categories_products` AS `AppModel` ON (`AppModel`.`product_id` = 20
AND `AppModel`.`category_id` = `Category`.`id`)  1  1   1

I test the last mysql query, it m'affiche the necessary information.
But on the controller, it just gives me information on the category.

I even do $ this-> Category-> recursive = 2;




Thank you in advance

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Paginar 2 Consultas de la misma tabla con la funcion paginate()

2011-10-08 Thread Bruno Binci
Hola, Estoy intentando hacer una paginacion de 2 tablas, el tema es el
siguiente:

tengo que mostrar el contenido de la tabla ordenado de esta manera:
today->present/future->past obviamente ordenándolo por fechas.

Tuve una idea de recuperar en un arreglo "Present" el contenido
ordenado de manera "today->present/future".
En otro "Past" ordenado "today->past".

Luego con la función array de php concatenarlos y formar un arreglo
maestro "all".

 
$all = array_merge($Present, $Past);

Hasta aquí todo bien, el problema fue que la funcion $this->paginate()
no acepta arreglos como parámetros, por lo tanto no puedo paginarlo.

Lo que se me ocurre ahora es: De alguna manera paginar una sola
consulta entre 2 tablas con UNION de MySQL, el tema seria... como le
paso a paginate esa consulta?

Como podría hacer un paginate de 2 tablas?

Vi por ahí que podría sobrescribir el método... pero no me agrada la
idea ya recién estoy comenzando con cake y no quiero tocar nada del
core.

Quedo a la espera de una respuesta que pueda servirme de ayuda.

Muchas Gracias!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: How REST works in Cake (how to have REST with CAKE :-) )

2011-10-08 Thread nowotny
On 5 Paź, 16:11, basav  wrote:
> I am trying to understand the some depth knowledge of working of REST
> in cake php

Check out this book: http://tinyurl.com/3c7kxdx the free sample
chapter deals with REST in Cake... It's not exactly what you asked for
but hopefully it'll be helpful...

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Retain custom parameter or query string in pagination

2011-10-08 Thread archer
Pagination in CakePHP 1.3 doesn't seems to provide a way to retain
custom query string passed with the url which is an essential part for
any application.
Say if  url is something like 
www.example.com/post/search?section=acticle&keyword=cakephp,
the pagination links  doesn't contain the query string passed. But it
can be easily achieved if we tweak pagination a bit. We can simply
pass  our  query string to options['url'] of Paginator with key '?'.
I used options() function  to set it so that it can be used for all
links generated by Paginator

  //In view file before any call to Paginator Helper
  //$this->params['url'] contains all the query string with key and
value
  $url_param = array_filter($this->params['url']); //strip out any
parameter which doen't have any value
  unset($url_param['url']); //its not the query string so unset it,
its the path to our action with any parameter to it
  $query_string = '';
  //cteate the query string with key and value
   foreach($url_param as $key => $val){
   $query_string .= '&'.$key.'='.$val;
   }
   //set 'url' key which will be used by paginator helper to set our
query string in pagination
   $options['url'] = array_merge($this->passedArgs, array('?'=>
$query_string));

  //call the options function which will set options variable of
Paginator Helpler
  $this->Paginator->options($options);

  Hope this issue will be fixed  in further releases.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Controllers Controller?

2011-10-08 Thread SyNeto
Hi, im pretty new in cakephp, so feel free to correct me,

I have read the phpcake blog tutorial, and i have some noobs questions
about controllers.

if i need a view to display information from more than one model, how
can i achive this task?

I have already read some information about elements in views and some
information about the ClassRegistry::init, but i dont know if i am in
the rigth path.

tanks.

Ernesto Jiménez Villseñor.

PS. sorry about my english.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: checking if Save() method was successful...

2011-10-08 Thread andrewperk
I may have said that wrong, I think it returns two different things,
if successful it will return an array if not I believe it just returns
false.

On Oct 8, 4:58 pm, andrewperk  wrote:
> Your model's save method doesn't actually return a boolean, you can
> just use the method call itself in a conditional, but it actually
> returns an array. You could check if $updated is not empty I believe:
>
> if (!empty($updated)) {
>
> }
>
> Or use the method call itself in a condition to see if the save was
> successful:
>
> if ($this->Report->save($updates)) {
>
> }
>
> On Oct 8, 8:30 am, Tomfox Wiranata  wrote:
>
>
>
>
>
>
>
> > hi,
>
> > i have a simple save()
>
> > $updates['Report']['status']= $new_status;
> > $updated = $this->Report->save($updates);
>
> > now i want to check, if the saving was successful and echo the result:
>
> > if ($updated)
> >                 {
> >                                 $this->set('success', "ok");
> >                                 $this->render('../elements/admin/success', 
> > 'ajax');
> >                 }
> >                 else
> >                 {
>
> >                         $this->set('success', "err");
> >                         $this->render('../elements/admin/success', 'ajax');
> >                 }
>
> > so even if i change the field "status" to "doesntexist", which makes
> > the saving a fail,  i dont get the "err" as a callback.
> > so i thought i should debug $updated to see what callback i get:
>
> > Array
> > (
> >     [Report] => Array
> >         (
> >             [fk_post_id] => 205
> >             [fk_user_id] => 74
> >             [reason] => test
> >             [description] => test
> >             [created] => 2011-10-07 22:15:21
> >             [id] => 44
> >             [fk_reporting_user_id] => 74
> >             [status] => pending
> >         )
> > more data ...
>
> > so $updated returns an array. i was expecting "true" or "false" ??? so
> > confusing..
>
> > what do i need to change?
>
> > thanks sooo much ;)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


Re: checking if Save() method was successful...

2011-10-08 Thread andrewperk
Your model's save method doesn't actually return a boolean, you can
just use the method call itself in a conditional, but it actually
returns an array. You could check if $updated is not empty I believe:

if (!empty($updated)) {

}

Or use the method call itself in a condition to see if the save was
successful:

if ($this->Report->save($updates)) {

}

On Oct 8, 8:30 am, Tomfox Wiranata  wrote:
> hi,
>
> i have a simple save()
>
> $updates['Report']['status']= $new_status;
> $updated = $this->Report->save($updates);
>
> now i want to check, if the saving was successful and echo the result:
>
> if ($updated)
>                 {
>                                 $this->set('success', "ok");
>                                 $this->render('../elements/admin/success', 
> 'ajax');
>                 }
>                 else
>                 {
>
>                         $this->set('success', "err");
>                         $this->render('../elements/admin/success', 'ajax');
>                 }
>
> so even if i change the field "status" to "doesntexist", which makes
> the saving a fail,  i dont get the "err" as a callback.
> so i thought i should debug $updated to see what callback i get:
>
> Array
> (
>     [Report] => Array
>         (
>             [fk_post_id] => 205
>             [fk_user_id] => 74
>             [reason] => test
>             [description] => test
>             [created] => 2011-10-07 22:15:21
>             [id] => 44
>             [fk_reporting_user_id] => 74
>             [status] => pending
>         )
> more data ...
>
> so $updated returns an array. i was expecting "true" or "false" ??? so
> confusing..
>
> what do i need to change?
>
> thanks sooo much ;)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


$this->Model->save($this->data)

2011-10-08 Thread aortizhi
hi, i have a problem when i'm trying to save data. I am creating new
fields to my database table as the user want to, but when trying to
save it does not include the values for the new fields in the insert
query, here's my code
my view:

Form->create('Proveedore',array('action' =>
'add1'));?>


Form->input($campos[$i]);
}
?>

";?>
 

Form->end(__('Submit', true));?>





Html->link(__('List Proveedores', true),
array('action' => 'index'));?>
Html->link(__('List Archivos Sistemas', 
true),
array('controller' => 'archivos_sistemas', 'action' => 'index')); ?> 
Html->link(__('New Archivos Sistema', 
true),
array('controller' => 'archivos_sistemas', 'action' => 'add')); ?> 




function addCampoNuevo(){
nombre=prompt ("Ingrese el nombre del nuevo campo que desea 
crear:
")

if (nombre!=""){

if(confirm("Esta seguro que desea crear este campo?\n 
Nombre del
Campo: "+nombre)){

var ni = document.getElementById("fooBar");

var newdiv = document.createElement('p');

newdiv.setAttribute('class',"nuevoDiv");

newdiv.innerHTML = 'Nombre del Campo';

ni.appendChild(newdiv);



//Create an input type dynamically.
var element = document.createElement("input");
//Assign different attributes to the element.
element.setAttribute("name", "camposNuevo[]");
element.setAttribute("type", 'text');
element.setAttribute("maxlength",'250');
element.setAttribute("readonly","readonly");
element.setAttribute("value",nombre);

var foo = document.getElementById("fooBar");
//Append the element in page (in span).
foo.appendChild(element);


//Create an input type dynamically.
var element1 = document.createElement("input");
//Assign different attributes to the element.
element1.setAttribute("name", "camposValor[]");
element1.setAttribute("type", 'text');

var foo = document.getElementById("fooBar");
//Append the element in page (in span).
foo.appendChild(element1);
document.forms[0].nombreNuevoCampo.value="";
}
}
}


as you can see i have a javascript to create new fields, and then i
make a get post in controller as follows:

function add1(){
$id=$this->RandomString(8);//id aleatoria para crear la copia
$resp=true;
while($resp){
$resp=$this->Proveedore->comprobarID($id);
$id=$this->RandomString(8);
}
$this->data['Proveedore']['id']=$id;
$nuevosCampos = $_POST['camposNuevo'];
$nuevosValores = $_POST['camposValor'];
$this->Proveedore->NuevosCampos($nuevosCampos);
for($i=0; $idata['Proveedore'][$nuevosCampos[$i]]=$nuevosValores[$i];
$this->data['Proveedore']['CampoG']="CampoG";
}
echo "Esta es la informacion que sube ";
print_r($this->data);



if($this->Proveedore->save($this->data)){
//$this->Proveedore->save($this->data);
//$this->Session->setFlash(__('The proveedore has been 
saved',
true));
//$this->redirect(array('action' => 'index'));
}else{
//$this->Session->setFlash(__('The proveedore could not 
be saved.
Please, try again.', true));
//$this->redirect(array('action' => 'add'));
}

}
in my model i have this function to create new fields to my models
table:
function NuevosCampos($nuevosCampos){
for($i=0; $iquery("ALTER TABLE `proveedores` ADD `".
$nuevosCampos[$i] ."` VARCHAR(255);");
}
}

the new fields are created, but the values that should be safe in the
new fields won't be save, and i add them to $this->data, am i doing
something wrong?:

here's what $this->data has when before $this->Proveedore->save($this-
>data):
Array ( [Proveedore] => Array ( [name] => nombre [Nit] => nit [nuevo
campo] => nuevo campo ) )

"nuevo campo" is the ne

Re: Associated models using wrong primary key

2011-10-08 Thread ShadowCross
Try adjusting your AccountUser model to explicitly specify the
AccountModule plugin relations:

class AccountUser extends AccountModuleAppModel {
...
var $hasMany = array(
    'AccountLicense' => array(
        'className' => 'AccountModule.AccountLicense',
        'foreignKey' => 'user_id'
    )
);

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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


checking if Save() method was successful...

2011-10-08 Thread Tomfox Wiranata
hi,

i have a simple save()


$updates['Report']['status']= $new_status;
$updated = $this->Report->save($updates);

now i want to check, if the saving was successful and echo the result:

if ($updated)
{
$this->set('success', "ok");
$this->render('../elements/admin/success', 
'ajax');
}
else
{

$this->set('success', "err");
$this->render('../elements/admin/success', 'ajax');
}


so even if i change the field "status" to "doesntexist", which makes
the saving a fail,  i dont get the "err" as a callback.
so i thought i should debug $updated to see what callback i get:


Array
(
[Report] => Array
(
[fk_post_id] => 205
[fk_user_id] => 74
[reason] => test
[description] => test
[created] => 2011-10-07 22:15:21
[id] => 44
[fk_reporting_user_id] => 74
[status] => pending
)
more data ...


so $updated returns an array. i was expecting "true" or "false" ??? so
confusing..

what do i need to change?

thanks sooo much ;)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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