BASH doesn't have boolean types. The existence of a program named 'true' doesn't change this.
BASH doesn't have associative arrays, either. You can't use words as array indexes.
That's a bit of a problem. Doing
Quote:
man bash
in section arrays, says that Bash provides one-dimensional indexed and associative array variables. Should work from bash 4.0 onward.
ksh should have associative arrays and can use the same logic. What would be the alternative to the true/false scheme I used. For single variables, the true/false should work. Or am I wrong in the conclusion. I tried it and did not encounter a problem.
---------- Post updated at 11:18 AM ---------- Previous update was at 10:37 AM ----------
I am running an Ubuntu Gutsy laptop with Advanced Compiz fusion options enabled. I am using xdotool to simulate keyboard input in order to rotate through multiple desktops.
I am looking for a way to kill a while true loop when the Enter key (or Control+C if it is easier) is pushed when the... (2 Replies)
Hi there,
im having issue with comparing two variables, in a bash script.
im trying to do the following:
- get a word from user 1
- split the word into array
- get a character from user2
trying to compare the character entered by user 2 with every single character in the array... (2 Replies)
:confused:
Is it possible to delete array elements dynamically.For instance,consider an array( a b c d ) ,now can i delete array (the third element 'c').So that the array becomes array(a b d)..
Thanks in advance!! (1 Reply)
Hi,
I am writing a bash shell script. I would like to execute a statement only if an array contains a specific value. For example:
array=(1 3 5 7)
I would like to execute the statement only if the value 3 is present in ${array}.
Thanks for any help,
Mike (1 Reply)
hi guys,
i have the following script and when i run it i get blank lines on the screen.. i am trying to display the contents of array var..
#!/usr/bin/bash
var=`awk 'NR>20&&NR<31' try.sum | awk '{print $4}'`
echo "${var}" (1 Reply)
hi i am using bash shell to perform some subraction. here is what i have:
i have a while loop and am using i as a counter.
diff= `expr ${ARRAY1} - ${ARRAY2}`
for example array1 has -0.7145 and array2 has -0.7041.
when i try the above command, i get expr: non-numeric argument. any... (6 Replies)
Hi all,
I have a file that contains many lines, but only a few are of my interest, so I'm cutting it with grep + awk, and the result I get is for example
line 0
line 1
line 2
line 3
line n
Now I want to store each line in an array "cell" so I can use it later calling to
${array},... (2 Replies)
Is there any command or VARIABLE in unix to display only bash builtin commands?. Some days back I worked on that, but now I do not remember.
Can anyone please reply for this?... (4 Replies)
Hey all,
This is my first post, and I am relatively new to linux/unix scripts. I am writing a bash script in which I am trying to extract one line from another file and parse specific words from the line into an array. So for example, I have a file called SortScans in which the first 5 lines... (9 Replies)
trying to sum elements in an array using bc and getopt,i have a file with names and thier vaules if the names appears 3 times i should multiply its value with 3 then find the sum of all the elements together
cat foo.txt
max 2.3
henry 3
fransis 4.5
max 2.3
henry 3
max 2.3
it should... (1 Reply)
Discussion started by: elginmulizwa
1 Replies
LEARN ABOUT PHP
sqlite_fetch_all
SQLITE_FETCH_ALL(3)SQLITE_FETCH_ALL(3)sqlite_fetch_all - Fetches all rows from a result set as an array of arraysSYNOPSIS
array sqlite_fetch_all (resource $result, [int $result_type = SQLITE_BOTH], [bool $decode_binary = true])
DESCRIPTION
Object oriented style (method):
array SQLiteResult::fetchAll ([int $result_type = SQLITE_BOTH], [bool $decode_binary = true])
array SQLiteUnbuffered::fetchAll ([int $result_type = SQLITE_BOTH], [bool $decode_binary = true])
sqlite_fetch_all(3) returns an array of the entire result set from the $result resource. It is similar to calling sqlite_query(3) (or
sqlite_unbuffered_query(3)) and then sqlite_fetch_array(3) for each row in the result set.
PARAMETERS
o $result
- The SQLite result resource. This parameter is not required when using the object-oriented method.
o $result_type
-The optional $result_type parameter accepts a constant and determines how the returned array will be indexed. Using SQLITE_ASSOC
will return only associative indices (named fields) while SQLITE_NUM will return only numerical indices (ordinal field numbers).
SQLITE_BOTH will return both associative and numerical indices. SQLITE_BOTH is the default for this function.
o $decode_binary
-When the $decode_binary parameter is set to TRUE (the default), PHP will decode the binary encoding it applied to the data if it
was encoded using the sqlite_escape_string(3). You should normally leave this value at its default, unless you are interoperating
with databases created by other sqlite capable applications.
RETURN VALUES
Returns an array of the remaining rows in a result set. If called right after sqlite_query(3), it returns all rows. If called after
sqlite_fetch_array(3), it returns the rest. If there are no rows in a result set, it returns an empty array.
The column names returned by SQLITE_ASSOC and SQLITE_BOTH will be case-folded according to the value of the sqlite.assoc_case configuration
option.
EXAMPLES
Example #1
Procedural example
<?php
$dbhandle = sqlite_open('sqlitedb');
$query = sqlite_query($dbhandle, 'SELECT name, email FROM users LIMIT 25');
$result = sqlite_fetch_all($query, SQLITE_ASSOC);
foreach ($result as $entry) {
echo 'Name: ' . $entry['name'] . ' E-mail: ' . $entry['email'];
}
?>
Example #2
Object-oriented example
<?php
$dbhandle = new SQLiteDatabase('sqlitedb');
$query = $dbhandle->query('SELECT name, email FROM users LIMIT 25'); // buffered result set
$query = $dbhandle->unbufferedQuery('SELECT name, email FROM users LIMIT 25'); // unbuffered result set
$result = $query->fetchAll(SQLITE_ASSOC);
foreach ($result as $entry) {
echo 'Name: ' . $entry['name'] . ' E-mail: ' . $entry['email'];
}
?>
SEE ALSO sqlite_fetch_array(3).
PHP Documentation Group SQLITE_FETCH_ALL(3)