Hmmm I’m trying to understand the api, I am doing a test to see if I can return all the alias information from the table modx_site_content
<?php
$results = $modx->db->select("alias", "modx_site_content", "", "alias", "60");
echo $results;
?>
It appears not to work and just shows resource 58, what am I doing wrong how to I show all the records?
I think that’s what PHP does when you try to output something like that. You can either loop through your rows with a loop of some kind, or if it is just for testing purposes as you say, I’m pretty sure
will output the contents of $results. Alternatively, maybe something like:
$total = mysql_num_rows ( $results );
echo "Your query found ".$total." results";
if($total>0):
while ( $row = mysql_fetch_assoc ( $results ) )
{
echo "> ".$row['alias']"<br />";
}
endif;
Something along those lines should give you something hopefully.
Hope that helps!
Taff
Adrian Lawley: www.adrianlawley.com
cheers taf, if I use print_r($results); it still produces Resource id #58
In my sql I got this from the documentation
$results = $modx->db->select("field1, field2", "table", "field = value", "field to order by", "limit value");
I have left the value "field = value" blank as I’m not sure what it does, is this why I get the error?
ah the problem was the field to order by, I left it blank and now it works
Thanks for the help, I can carry on playing now.
Pleasure, glad you sorted it.
On a sidenote, the URL in your signature has a l in the top level domain sending it to col.uk as opposed to co.uk
:)
Taff (with 2 "F"s as in the river in Wales)
Adrian Lawley: www.adrianlawley.com
ah I never noticed that, will fix it now