I am having an issue setting data to Session. I have an array in
Session:

Devices.Staging

I want to add a device to the array using the device_id as a key. I
expect something similar to the following:

Devices.Staging.12345678901 = device
Devices.Staging.12345678902 = device

The problem is that my device_id dont seem to work with Session. I am
99% sure its because the ids start with numerals. Because device_ids
that start with an alpha character work without any problems. In
addition if I append an alpha char to the numeric ID it works.

I dont understand why this would be. I am using the device_id as a
string. I have opened up the session.php file and verified that its a
string.

$this->Session->write("Devices.Staging.$device_id",
$query_device_response->queryDeviceRsp);

Another mystery is that the key is replaced by another string of
digits. I dont know where or how this string is generated but its the
same every time.

The following method takes an array of device_id and iterates through
it. On each iteration it will attempt to pull back the device record
from the API. Then it will add the device id and device record as a
key and value respectively to Devices.Staging

        public function add_devices_to_staging()
        {
                Logger::write($this->params['form']['device_ids']);
                foreach($this->params['form']['device_ids'] as $device_id)
                {
                        $query_device_response = 
$this->TriadApi->QueryDevice($device_id);
                        $this->Session->write("Devices.Staging.$device_id",
$query_device_response->queryDeviceRsp);
                }

                Logger::write($this->Session->read('Devices'));
                $response['status'] = 'success';
                $this->set('response', json_encode($response) );
                $this->render('/elements/ajax_response', 'ajax');
        }

As I said previously this only an issue of the key starts with
numbers. Here is the log output. Notice the array of device_ids and
the last device is the only one in Devices.Staging which means that
the mystery key '2147483647' is being used over and over.



2009-11-20 14:34:36 : Array
(
    [0] => 123456789010
    [1] => 123456789011
    [2] => 123456789013
    [3] => 123456789017
)

2009-11-20 14:34:36 : Array
(
    [Staging] => Array
        (
            [2147483647] => stdClass Object
                (
                    [DeviceId] => 123456789017
                    [DeviceBasics] => stdClass Object
                        (
                            [DeviceType] => SA Explorer
                            [DeviceModel] => Explorer 8300HD MR
                            [DeviceStatus] => Stock
                            [UnitAddress] =>
                            [HostId] =>
                            [SecurityData] =>
                            [CustomFieldList] => stdClass Object
                                (
                                    [CustomField] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [FieldLabel] => SA
Model
                                                    [FieldValue] =>
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [FieldLabel] =>
Room Location
                                                    [FieldValue] =>
Undefined
                                                )

                                        )

                                )

                        )

                    [Location] => stdClass Object
                        (
                            [LocationId] => HEADEND 01 INVENTORY
                            [HeadendCode] => 01
                            [NetLocCode] =>
                            [Address1] =>
                            [Address2] =>
                            [City] =>
                            [State] =>
                            [Zip] =>
                            [CustomFieldList] => stdClass Object
                                (
                                    [CustomField] => Array
                                        (
                                            [0] => stdClass Object
                                                (
                                                    [FieldLabel] =>
Drop Type
                                                    [FieldValue] =>
                                                )

                                            [1] => stdClass Object
                                                (
                                                    [FieldLabel] =>
Number of Outlets
                                                    [FieldValue] =>
                                                )

                                            [2] => stdClass Object
                                                (
                                                    [FieldLabel] =>
Location Type
                                                    [FieldValue] =>
                                                )

                                        )

                                )

                        )

                )

        )

)

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.


Reply via email to