020 555 1111
  • Old fashion, modular, procedural PHP plus some scaffolding techniques to allow it to mimic MVC simplicity.
  • A quick reference to help you find in PHP maze what needs to be done and how to do it.
  • Learn a PHP Object Oriented Programming by building a live discussion forum application.
  • MVC - Model View Controller - real life, easy reference and application.
This product has options, take a look at them and select ones you like the most.
Options are displayed under image section.

PDO::FETCH_FUNC
[MySQL PDO Const]

PDO::FETCH_FUNC (integer)

Returns the results of calling the specified function, using each row's columns as parameters in the call.

Used with:

  • PDOStatement:: fetchAll  [more]

 

 

PDOStatement::fetchAll

code:

function func ($entry_title, $entry_body, $status) {
    return $entry_title.'--||--'.$entry_body.'--||--'.$status;
}

$sql = "SELECT entry_title, entry_body, status FROM posts";
$stmt = $dbh->query($sql);
$result = $stmt->fetchAll(PDO::FETCH_FUNC, 'func');

print_r($result);
var_dump($result);

output:

print_r:

Array
(
    [0] => post 1--||--1: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0
    [1] => post 2--||--2: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0
    [2] => post 3--||--3: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0
    [3] => post 4--||--4: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0
)

var_dump:

array
     0 => string 'post 1--||--1: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0' (length=343)
     1 => string 'post 2--||--2: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0' (length=343)
     2 => string 'post 3--||--3: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0' (length=343)
     3 => string 'post 4--||--4: Lorem ipsum dolor sit amet, consectetur adipiscing elit.--||--0' (length=343)