PHP 8.5.0 Beta 1 available for testing

Voting

: six plus three?
(Example: nine)

The Note You're Voting On

benpptung at tacol dot biz
16 years ago
I don't know why no one talk about this.
fetch_object is very powerful since you can instantiate an Object which has the methods you wanna have.

You can try like this..

<?php
class PowerfulVO extends AbstractWhatEver {

public
$field1;
private
$field2; // note : private is ok

public function method(){
// method in this class
}
}

$sql = "SELECT * FROM table ..."
$mysqli = new mysqli(........);
$result = $mysqli->query($sql);
$vo = $result->fetch_object('PowerfulVO');
?>

Note : if the field is not defined in the class, fetch_object will add this field for you as public.

The method is very powerful, especially if you want to use a VO design pattern or class mapping feature with Flex Remoting Object( Of course, you need to have ZendAMF or AMFPHP ..framework)

Hope this help and open new possibilities for you

<< Back to user notes page

To Top