associative-array

ORA-21700: object does not exist or is marked for delete for Associative Array as input parameter called from ODP.NET

若如初见. 提交于 2019-12-02 01:02:14
I have this package code on Oracle 12c CREATE OR REPLACE PACKAGE Support_Data_Types AS TYPE ttDate IS TABLE OF DATE END Support_Data_Types; PROCEDURE GetData ( tabDates IN SUPPORT_DATA_TYPES.TTDATE, ) AS BEGIN SELECT count(*) INTO n FROM table(tabDates); END GetData; If I call it from PL/SQL code it works declare dates SUPPORT_DATA_TYPES.TTDATE; begin dates(1) := To_DATE('12/31/2005','MM/DD/YYYY'); dates(2) := To_DATE('03/31/2006','MM/DD/YYYY'); dates(3) := To_DATE('06/30/2006','MM/DD/YYYY'); dates(4) := To_DATE('09/30/2006','MM/DD/YYYY'); MyPackage.GETVALUE(dates); end; But If I call it from

Search and replace inside an associative array

南楼画角 提交于 2019-12-01 20:23:08
I need to search and replace inside an associative array. ex: $user = "user1"; // I've updated this $myarray = array("user1" => "search1", "user2" => "search2", "user3" => "search1" ) ; I want to replace search1 for search4 . How can I achieve this? UPDATE: I forgot to mention that the array has several search1 values and I just want to change the value where the key is == $user . Sorry for not mention this earlier. $myarray = array("user1" => "search1", "user2" => "search2" ); foreach($myarray as $key => $val) { if ($val == 'search1') $myarray[$key] = 'search4'; } There's a function for this

PHP - Make my query's array's key the ID

左心房为你撑大大i 提交于 2019-12-01 18:03:59
问题 So I have this array of images pulling and the array's keys are just 0,1,2,3,4,5.... and whatnot... How can I make the value in the 'id' column of that table the key, and keep 'link' as the value. Associative Array, no? Here is my PHP: $myImageID = $me['imageid']; $findImages = "SELECT link FROM images WHERE model_id ='{$me['id']}'"; $imageResult = mysql_query($findImages) or die (mysql_error()); $myImages = array(); while($row = mysql_fetch_array($imageResult)) { $myImages[] = $row[0]; }

Multiple MYSQL queries vs. Multiple php foreach loops

谁都会走 提交于 2019-12-01 17:36:45
Database structure: id galleryId type file_name description 1 `artists_2010-01-15_7c1ec` `image` `band602.jpg` `Red Umbrella Promo` 2 `artists_2010-01-15_7c1ec` `image` `nov7.jpg` `CD Release Party` 3 `artists_2010-01-15_7c1ec` `video` `band.flv` `Presskit` I'm going to pull images out for one section of an application, videos on another, etc. Is it better to make multiple mysql queries for each section like so: $query = mysql_query("SELECT * FROM galleries WHERE galleryId='$galleryId' && type='image'); ...Or should I be building an associative array and just looping through the array over and

Clojure macro that will conserve associative map order

浪子不回头ぞ 提交于 2019-12-01 17:25:16
To preface, I am on Windows 7 (64-bit), running Java version 6 (update 33) using clooj as my IDE. I have not tried to reproduce my problem in any other system. I am experienced with Clojure, but not at all with Java. The entirety of the problem I am trying to solve is lengthy to describe, but it boils down to this: let's say I would like to a make a macro that takes one argument, an associative map, and returns a vector of the elements of the map with their order conserved. =>(defmacro vectorize-a-map [associative-map] (vec associative-map)) =>#'ns/vectorize-a-map =>(vectorize-a-map {:a 1 :b 2

Does a PHP array need to be declared before use?

微笑、不失礼 提交于 2019-12-01 16:00:33
While writing a recent application I accidentally started filling an array before I had declared it. error_reporting ( E_ALL); $array['value'] = 'Test string'; I use E_ALL error reporting and an error was not thrown. Is this correct? And if so, are there any issues with declaring array values whilst never declaring the actual array? Perhaps it just doesn't follow good programming standards. While writing a recent application I accidentally started filling an array before I had declared it. PHP is a weakly typed language. Your statement: $array['value'] = 'Test string'; is an implicit

Getting the key of the only element in a PHP array

北战南征 提交于 2019-12-01 15:26:25
The key of the associative array is dynamically generated. How do I get the "Key" of such an array? $arr = array ('dynamic_key' => 'Value'); I am aware that It is possible to access it through a foreach loop like this: foreach ($arr as $key => $val) echo "Key value is $key"; However, I know that this array will have only one key and want to avoid a foreach loop. Is it possible to access the value of this element in any other way? Or get the key name? edit: http://php.net/each says: each Warning This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

How can I get sed to change all of the instances of each letter only once?

丶灬走出姿态 提交于 2019-12-01 14:35:10
So far, the code only changes the first letter. If I take the break out, then it changes each instance of a letter more than once (which is bad). I'm simply attempting a caesar cipher using sed. I realize I could use tr to perform text transformations, but I'd prefer to stick with sed. echo "What number do you want to use for the shift?" read num declare -A origin x=({a..z}) case "$num" in 0) y=({a..z});;1)y=({{b..z},a});;2)y=({{c..z},a,b});;3)y=({{d..z},a,b,c});;4)y=({{e..z},a,b,c,d});;5)y=({{f..z},{a..e}});; 6)y=({{g..z},{a..f}});;7)y=({{h..z},{a..g}}) ;; 8) y=({{i..z},{a..h}}) ;; 9) y=({{j.

array_unique for arrays inside array

浪尽此生 提交于 2019-12-01 13:51:10
问题 I need a function like array_unique for arrays inside array. The Case - should be equal, but output "not equal": <?php $arr=array(array('a',1),array('a',2)); $arr2=array_unique($arr); if($arr2==$arr){ echo "equal"; } else{ echo "not equal"; } ?> How should the code be changed to get output "equal"? 回答1: You should modify your call for array_unique to have it include the SORT_REGULAR flag. $arr2 = array_unique($arr, SORT_REGULAR); 回答2: If you want to test if the outer array has unique entries,

How can I get sed to change all of the instances of each letter only once?

五迷三道 提交于 2019-12-01 12:14:54
问题 So far, the code only changes the first letter. If I take the break out, then it changes each instance of a letter more than once (which is bad). I'm simply attempting a caesar cipher using sed. I realize I could use tr to perform text transformations, but I'd prefer to stick with sed. echo "What number do you want to use for the shift?" read num declare -A origin x=({a..z}) case "$num" in 0) y=({a..z});;1)y=({{b..z},a});;2)y=({{c..z},a,b});;3)y=({{d..z},a,b,c});;4)y=({{e..z},a,b,c,d});;5)y=(