<![CDATA[ MySQL calls with MODx Revolution - My Forums]]> https://forums.modx.com/thread/?thread=31025 <![CDATA[Re: MySQL calls with MODx Revolution]]> https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168091 ]]> Tontttu Mar 12, 2011, 08:48 AM https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168091 <![CDATA[Re: MySQL calls with MODx Revolution]]> https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168090
$c->limit(2);


This would get the next 10 starting with the third one.
$c->limit(10,2);


:)]]>
BobRay Mar 09, 2011, 09:09 PM https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168090
<![CDATA[Re: MySQL calls with MODx Revolution]]> https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168089

How I can set a limit for the articles that the script will show? I want to print only two newest articles at a time.]]>
Tontttu Mar 09, 2011, 07:54 PM https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168089
<![CDATA[Re: MySQL calls with MODx Revolution]]> https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168088
<?php
$c = $modx->newQuery('modResource');
$c->select(array('id', 'pagetitle', 'parent', 'description', 'content'));

$c->where(array(
   'published'=>'1',
   'deleted'=>'0',
   'parent'=>'3',
));

$c->sortby('id', 'DESC');

$docs = $modx->getCollection('modResource', $c);

foreach ($docs as $doc) {
    $output .= '<br />Title:' . $doc->get('pagetitle') . ' ID:' . $doc->get('id') .'<br />';
}
return $output;

]]>
BobRay Mar 09, 2011, 06:40 PM https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168088
<![CDATA[MySQL calls with MODx Revolution]]> https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168087
When I had MODx evolution, I used following code to get information from the database:
<?php
$haku = mysql_query( "SELECT id, pagetitle, parent, description, content FROM `revo_site_content` WHERE `parent`=3 ORDER BY `id` DESC  LIMIT 2");

while ( $tiedot = mysql_fetch_array ( $haku ) )
{

}
?>


When I installed the MODx Revolution, this code doesn’t work anymore. I read that with the Revolution I have to use some ORM or xPDO thing but I have no idea how to use them... And haven’t found anythind easy enough for me. So could you help me with that? How I can get those information from my MySQL database with the Revolution?

Thank you! smiley]]>
Tontttu Mar 09, 2011, 01:45 PM https://forums.modx.com/thread/31025/mysql-calls-with-modx-revolution#dis-post-168087