associative-array

How to use an Oracle Associative Array in a SQL query

旧巷老猫 提交于 2019-11-27 15:07:15
问题 ODP.Net exposes the ability to pass Associative Arrays as params into an Oracle stored procedure from C#. Its a nice feature unless you are trying to use the data contained within that associative array in a sql query. The reason for this is that it requires a context switch - SQL statements require SQL types and an associative array passed into PL/SQL like this is actually defined as a PL/SQL type. I believe any types defined within a PL/SQL package/procedure/function are PL/SQL types while

Comment associative array in PHP Documentor

狂风中的少年 提交于 2019-11-27 14:38:26
I use several associative arrays in my PHP application and I'm using PHP documentor to comment my sources. I never really did specify comments for the arrays in an array, but now I need to do that and don't know how. $array = array('id' => 'test', 'class' => 'tester', 'options' => array('option1' => 1, 'option2' => 2)) How do I comment this array in the correct way for @var and @param comments? I could do this like this, but I don't know if this is correct: @param string $array['id'] @param string $array['class'] @param int $array['options']['option1'] But how to do this for the @var part? You

javascript Associate array

十年热恋 提交于 2019-11-27 14:23:53
问题 In python I could do something like myMap = {key: [value1, value2]} and then access the value2 using myMap[key][1] Can I do something like this in javascript? 回答1: Well, you can do this: var myMap = { key: [ value1, value2 ] }; var array = myMap.key; // or myMap["key"] JavaScript doesn't have an "associative array" type, one that combines "map" behavior with array behavior like keeping track of the number of properties. Thus the common thing to do is use a plain object. In modern JavaScript

Automatically sorted by values map in Java

邮差的信 提交于 2019-11-27 13:56:24
I need to have an automatically sorted-by-values map in Java - so that It keeps being sorted at any time while I'm adding new key-value pairs or update the value of an existing key-value pair, or even delete some entry. Please also have in mind that this map is going to be really big (100's of thousands, or even 10's of millions of entries in size). So basically I'm looking for the following functionality: Supposed that we had a class 'SortedByValuesMap' that implements the aforementioned functionality and we have the following code: SortedByValuesMap<String,Long> sorted_map = new

Ruby : Associative Arrays

喜欢而已 提交于 2019-11-27 12:55:29
问题 Does Ruby on rails have associative arrays? For eg: a = Array.new a["Peter"] = 32 a["Quagmire"] = 'asdas' What is the easiest method to create such an array structure in Ruby? 回答1: Unlike PHP which conflates arrays and hashes, in Ruby (and practically every other language) they're a separate thing. http://ruby-doc.org/core/classes/Hash.html In your case it'd be: a = {'Peter' => 32, 'Quagmire' => 'asdas'} There are several freely available introductory books on ruby and online simulators etc.

php: how to get associative array key from numeric index?

断了今生、忘了曾经 提交于 2019-11-27 11:37:55
If I have: $array = array( 'one' =>'value', 'two' => 'value2' ); how do I get the string one back from $array[1] ? You don't. Your array doesn't have a key [1] . You could: Make a new array, which contains the keys: $newArray = array_keys($array); echo $newArray[0]; But the value "one" is at $newArray[0] , not [1] . A shortcut would be: echo current(array_keys($array)); Get the first key of the array: reset($array); echo key($array); Get the key corresponding to the value "value": echo array_search('value', $array); This all depends on what it is exactly you want to do. The fact is, [1] doesn

Javascript: Using integer as key in associative array?

喜你入骨 提交于 2019-11-27 09:48:34
问题 When I create a new javascript array, and use an integer as a key, each element of that array up to the integer is created as undefined. for example: var test = new Array(); test[2300] = 'Some string'; console.log(test); will output 2298 undefined's and one 'Some string'. How should I get javascript to use 2300 as a string instead of an integer, or how should I keep it from instanciating 2299 empty indices? 回答1: Use an object, as people are saying. However, note that you can not have integer

PHP/SQL Insert Error when using Named Placeholders

假如想象 提交于 2019-11-27 09:48:28
I have the following PHP PDO statement: $STH = $this->_db->prepare("INSERT INTO UserDetails (FirstName, LastName, Address, City, County, PostCode, Phone, Mobile, Sex, DOB, FundraisingAim, WeeksAim, LengthsAim, HearAboutID, MotivationID, WelcomePackID, ContactPrefID, TitleID) VALUES (:firstName, :lastName, :address, :city, :county, :postCode, :phone, :mobile, :sex, :DOB, :fundraisingAim, :weeksAim, :lengthsAim, :hearAbout, :motivation, :welcomePackPref, :contactPref, :title)"); $STH->execute($userData); Where $userData is an associative array. I've double checked the names and I don't

How to echo element of associative array in string?

谁说我不能喝 提交于 2019-11-27 08:31:24
问题 I know It's a very basic question but I have to ask. I have an associative array let's say it is: $couple = array('husband' => 'Brad', 'wife' => 'Angelina'); Now, I want to print husband name in a string. There are so many ways but i want to do this way but it gives html error $string = "$couple[\'husband\'] : $couple[\'wife\'] is my wife."; Please correct me if I'm using a wrong syntax for backslash. 回答1: Your syntax is correct. But, still you can prefer single quotes versus double quotes.

Finding the minimum value's key in an associative array

心不动则不痛 提交于 2019-11-27 08:12:31
In PHP, say that you have an associative array like this: $pets = array( "cats" => 1, "dogs" => 2, "fish" => 3 ); How would I find the key with the lowest value? Here, I'd be looking for cats . Is there some built in PHP function that I've missed which does this? It would also be great if there was a solution that accounted for several values being identical, as below: $pets = array( "cats" => 1, "dogs" => 1, "fish" => 2 ); Above, I wouldn't mind if it just output either; cats or dogs . Thanks in advance. array_keys is your friend: $pets = array( "cats" => 1, "dogs" => 2, "fish" => 3 ); array