Re: Unexpected values in an associative array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jul 31, 2007, at 12:06 PM, Instruct ICC wrote:

array(6) {
  ["task_id"]=>
  int(22)
  [0]=>
  string(2) "22"
  ["container_id"]=>
  int(3784)
  [1]=>
  string(4) "3784"
  ["name"]=>
  string(12) "108-6972.XTG"
  [2]=>
  string(24) "3130382D363937322E585447"
}

What is $coersions or $inQuery['coersions']? Maybe a var_dump or a print_r on that for the list?

For the above record, $coersions is an associative array of the form

array('task_id'=> 'integer', 'container_id'=> 'integer', 'name'=>'hex_decode');

I found that I was doing a lot of coersions with results of SQL queries to turn them into real integers, floats or decode from base64/ hex before I could use them so rolling all that ugly stuff into the query makes it so users of the function don't have to do coersions any more. There may be a better way to perform coersions from string types returned by PDO queries and their real types but I'm a PDO noob so don't know if one.

What is $value and what is this supposed to do:
							case	'integer':
									$value 		+= 0;
									break;

							case	'float':
									$value 		+= 0.0;

If $value is a string, you should quote your 0 and 0.0. What add 0 or 0.0 to an int or float respectively?

The point of these is to convert the strings to ints, floats, decode them etc...

What's the extra "[]" about in $rows[$groupKey][]		= $fields;
Maybe that's where your duplicates are coming from although I don't see duplicates in your output.

Another thing I found the need for was to group rows in a select result by specific keys. For example say a query gets all ads in a publication, and you want to physically group them by page. That's what that group function does.

Ken

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux