Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pg_fetch_all(3) [php man page]

PG_FETCH_ALL(3) 														   PG_FETCH_ALL(3)

pg_fetch_all - Fetches all rows from a result as an array

SYNOPSIS
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 array

SYNOPSIS
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)
Man Page

13 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to return an array of elements from oracle to shell script

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)
Discussion started by: satyakiran
3 Replies

2. Shell Programming and Scripting

From File to Array

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)
Discussion started by: Rock
2 Replies

3. Shell Programming and Scripting

output of an array

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)
Discussion started by: ragha81
3 Replies

4. Shell Programming and Scripting

Split A String

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)
Discussion started by: newbie187
2 Replies

5. Shell Programming and Scripting

Reading Of Array Element in Unix

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)
Discussion started by: ravi_rn
2 Replies

6. Shell Programming and Scripting

Extraction of the output from a string.

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)
Discussion started by: saicharantej
5 Replies

7. Shell Programming and Scripting

Array not initializing

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)
Discussion started by: nandanjain
3 Replies

8. UNIX for Dummies Questions & Answers

array error

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)
Discussion started by: temhem
2 Replies

9. Programming

Checking an array for NULL in C++

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)
Discussion started by: mind@work
3 Replies

10. Shell Programming and Scripting

Array and field separator

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)
Discussion started by: Dedalus
3 Replies

11. Shell Programming and Scripting

Store the output values in array

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)
Discussion started by: KarthikPS
2 Replies

12. Shell Programming and Scripting

Need to have output of AWK array in one line

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)
Discussion started by: Jotne
4 Replies

13. Shell Programming and Scripting

Arrays in awk

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)
Discussion started by: guitarist684
6 Replies