forked from pods-framework/pods
-
Notifications
You must be signed in to change notification settings - Fork 0
Data()
bonsak edited this page Nov 20, 2012
·
1 revision
Return an array of all rows returned from a find() call. Most of the time, you will want to loop through data using fetch() instead of using this function.
public function data ()
(array) or (bool) An array of all rows returned from a find() call, or false if no items returned
<?php
$params = array(
'orderby' => 't.birth_date ASC',
'where' => 't.birth_date < "1972"',
'limit' => -1 // Return all rows
);
// find() will be called when you give an array to pods()
$people = pods( 'people', $params );
$all_rows = $people->data();
if ( !empty( $all_rows ) ) {
foreach( $all_rows as $this_person ) {
?>
<h2><?php echo $this_person->name; ?></h2>
<p>Favorite Color: <?php echo $this_person->favorite_color; ?></p>
<br />
<?php
}
}
else
echo '<strong>No people found.</strong>';
<h2>Fred Flintstone</h2>
Favorite Color: Blue
<br />
<h2>Phil Lewis</h2>
Favorite Color: Yellow
<br />
2.0+
data() is located in /pods/classes/Pods.php