PG_FETCH_ALL(3)PG_FETCH_ALL(3)pg_fetch_all - Fetches all rows from a result as an arraySYNOPSIS
array pg_fetch_all (resource $result)
DESCRIPTION pg_fetch_all(3) returns an array that contains all rows (records) in the result resource.
Note
This function sets NULL fields to the PHP NULL value.
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
RETURN VALUES
An array with all rows in the result. Each row is an array of field values indexed by field name.
FALSE is returned if there are no rows in the result, or on any other error.
EXAMPLES
Example #1
PostgreSQL fetch all
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occurred.
";
exit;
}
$result = pg_query($conn, "SELECT * FROM authors");
if (!$result) {
echo "An error occurred.
";
exit;
}
$arr = pg_fetch_all($result);
print_r($arr);
?>
The above example will output something similar to:
Array
(
[0] => Array
(
[id] => 1
[name] => Fred
)
[1] => Array
(
[id] => 2
[name] => Bob
)
)
SEE ALSO pg_fetch_row(3), pg_fetch_array(3), pg_fetch_object(3), pg_fetch_result(3).
PHP Documentation Group PG_FETCH_ALL(3)
Check Out this Related Man Page
PG_FETCH_ALL_COLUMNS(3)PG_FETCH_ALL_COLUMNS(3)pg_fetch_all_columns - Fetches all rows in a particular result column as an arraySYNOPSIS
array pg_fetch_all_columns (resource $result, [int $column])
DESCRIPTION pg_fetch_all_columns(3) returns an array that contains all rows (records) in a particular column of the result resource.
Note
This function sets NULL fields to the PHP NULL value.
PARAMETERS
o $result
- PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others).
o $column
- Column number, zero-based, to be retrieved from the result resource. Defaults to the first column if not specified.
RETURN VALUES
An array with all values in the result column.
FALSE is returned if $column is larger than the number of columns in the result, or on any other error.
EXAMPLES
Example #1
pg_fetch_all_columns(3) example
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occurred.
";
exit;
}
$result = pg_query($conn, "SELECT title, name, address FROM authors");
if (!$result) {
echo "An error occurred.
";
exit;
}
// Get an array of all author names
$arr = pg_fetch_all_columns($result, 1);
var_dump($arr);
?>
SEE ALSO pg_fetch_all(3).
PHP Documentation Group PG_FETCH_ALL_COLUMNS(3)
Hi all,
I have a interresting problem. My application is as follows:
From a shell script i will conn to a oracle database and fetch few rows using a select statement.
Then i want to sort these rows and return a column (collection of values of a column from the selected results) as array... (3 Replies)
Hi all,
I want to store the records from a file to an array. What approach can I use?
e.g.
soruce_file:
aaa
bbb
ccc
array:
arr=aaa
arr=bbb
arr=ccc
Thanks,
Rock (2 Replies)
Hi gurus,
I need to set up an array like this
set - A arr 'A', 'B'
The output of this array should be like this 'A','B'
Right now, I get the output like this 'A B'
Can anyone suggest me on how to achieve this.
thanks (3 Replies)
Hi,
I am new to scripting and need help splitting a string using space as the delimiter.
How can I do that?
I want the result to be stored in an Array.
I tried using
set -A arr $(echo $FILE)
echo $arr
The result of the above was ''.
Thanks. (2 Replies)
Hi,
I am using the following command to initialize and array
# arr=ffffff00
# echo $arr
ffffff00
my requirement is i want to fetch the one by one character from array.
I don't know how to fetch one by one charcter from array.
Please i need an help.
Thank you very much
Ravi R N (2 Replies)
Hi Everyone,
I stored the result of a certain awk script in the variable arr.The result is /inets /banking /tools.
arr= /inets /banking /tools
These are 3 direcctories. I should be able to move in to these directories using "cd" command.Can you tell me how to extract... (5 Replies)
Hi,
I have to use array in shell script to perform a logic. When I use below statements inside a script and execute, it gives me an error:
$ cat test.sh
set -A arr 10 20 30
echo ${arr}
$ sh test.sh
a: -A: bad option(s)
But at the same time I can run above two statements without error... (3 Replies)
hi all,
when i use array like this:
array=223
echo ${array}
result is :
array: 1,2: syntax error
thanx.
---------- Post updated at 09:21 AM ---------- Previous update was at 09:20 AM ----------
sorry, i had written wrongly.
when i use array like this:
array=223
echo... (2 Replies)
Hello All,
I have this question that how to check for an array for NULL?
For eg.
#include<iostream.h>
using namespace std;
int main()
{
char arr;
if(arr == NULL)
{
cout<<"NULL";
}
}
Thanks a lott in advance!!! (3 Replies)
Hi all,
I have an array in BASH and I need to change the IFS in order to split up it correctly.
Here an example:
array_test=(hello world+sunny)
for elem in ${array_test}; do
echo $elem
done
echo -e "\n changed IFS \n"
OLD_IFS=$IFS
IFS=+
for elem in ${array_test}; do
echo... (3 Replies)
Hi,
How to store the values in array from output result,
EG:
I have the result like this,
ps, google, 1.txt, 1
sam, google, 2.txt, 2
These are the four values followed by comma in two sets. I need to store these values set by set. One set contains four values followed by comma.
... (2 Replies)
I have this code
echo $logfile | awk ' {arr++; next} END { for (i in arr) {print i} }'
that gives me this output
result1
result2
result3
I try to figure out how to get it like this
result1 result2 result3 (4 Replies)
Array A contains lines of numbers from files. Array B contains number of fields for each line of each file.
I want to run on array A. To do that I need to know the number of fields for each file in array A (because each line doesn't have the same NF).
The NF is in array B, problem is: I don't... (6 Replies)