Also, here's the structure of the data that it tries to save. I think
it looks exactly like the example in the book, but it just won't
update anything.

Array
(
    [Product] => Array
        (
            [0] => Array
                (
                    [id] => 1021
                    [upc] => 731352528880
                    [name] => SIGNA 5 FRM RH WP OYS
                    [price] => 2267.00
                    [discount] =>
                    [status_id] => 1
                )

            [1] => Array
                (
                    [id] => 1025
                    [upc] => 731352023019
                    [name] => SIGNA 6 WB LH BLK
                    [price] => 2475.00
                    [discount] =>
                    [status_id] => 1
                )

            [2] => Array
                (
                    [id] => 1036
                    [upc] => 731352528958
                    [name] => SIGNA 5 FLM LH WP OYS
                    [price] => 2267.00
                    [discount] =>
                    [status_id] => 1
                )
etc.



On Jun 30, 3:56 pm, "[email protected]" <[email protected]> wrote:
> Hi all,
>
> I'm trying to save/update a number of rows from a grid into a table
> with a single command. According to the documentation the SaveAll
> command should do this. However, I get nothing...
>
> (default) 26 queries took 149 ms Nr     Query   Error   Affected        Num. 
> rows
> Took (ms)
> 23      START TRANSACTION               0               1
> 24      COMMIT
>
> Here's the view...
>
> <?php
>         //pr($statuses);
>         $id = 0;
>         foreach($products as $product) {
>                 echo '<tr>';
>                 echo '<input type="hidden" name="data[Product]['.$id.'][id]"
> value="'.$product['Product']['id'].'">';
>                 echo '<td><input type="text" 
> name="data[Product]['.$id.'][upc]"
> value="'.$product['Product']['upc'].'" size="12"></td>';
>                 echo '<td><input type="text" 
> name="data[Product]['.$id.'][name]"
> value="'.$product['Product']['name'].'" size="45"></td>';
>                 echo '<td><input type="text" 
> name="data[Product]['.$id.'][price]"
> value="'.$product['Product']['price'].'" size="5"></td>';
>                 echo '<td><input type="text" 
> name="data[Product]['.$id.'][discount]"
> value="'.$product['Product']['discount'].'" size="5"></td>';
>                 echo "\n";
>                 echo '<td><select name="data[Product]['.$id.'][status_id]"
> size="1">';
>                 foreach($statuses as $status) {
>                         $checked = '';
>                         if ($status['Status']['id'] == 
> $product['Product']['status_id']) {
>                                 $checked = 'selected';
>                         }
>                         echo '<option value="'.$status['Status']['id'].'" 
> '.$checked.'>'.
> $status['Status']['name'].'</option>';
>                 }
>                 echo '</select></td>';
>                 echo '</tr>';
>                 echo "\n";
>                 $id++;
>         }
> ?>
>
> And the controller...
>
>                 $this->Product->SaveAll($this->data, array( 'fieldList' =>
> array('Product.id', 'Product.upc', 'Product.name',
> 'Product.status_id', 'Product.price', 'Product.discount')));
>
> And finally my database table...
>
> CREATE TABLE `products` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `upc` char(12) NOT NULL,
>   `name` varchar(45) NOT NULL,
>   `status_id` int(11) NOT NULL DEFAULT '1',
>   `price` decimal(10,2) DEFAULT NULL,
>   `discount` decimal(10,2) DEFAULT NULL,
>   `product_code` varchar(45) DEFAULT NULL,
>   `created` datetime DEFAULT NULL,
>   `modified` datetime DEFAULT NULL,
>   `created_by` char(36) DEFAULT NULL,
>   `modified_by` char(36) DEFAULT NULL,
>   PRIMARY KEY (`id`),
>   UNIQUE KEY `upc_UNIQUE` (`upc`)
> )
>
> Any ideas would be much appreciated!!!

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