Hello, excuse the obvious question for many ...
I need to make a query directly to db, but I do not know how to do it.
for example, if I wanted to get, through sql query, all the children of a resource beginning with the letter a? How to do it without using Ditto or Wayfinder?
many thanks
"Destiny is not a matter of chance, it's a matter of choice"
-
☆ A M B ☆
- 300 Posts
how to compose a snippet:
http://sottwell.com/create-snippets.html
DB API
http://wiki.modxcms.com/index.php/API:DBAPI:query
or I think theoretically you can use an @SELECT TV to do what you want.
http://sottwell.com/tv-bindings.html
hope some of that helps.
[ed. note: redtoad last edited this post 15 years, 1 month ago.]
thx at all,
i have tried to create a snippet like this:
<?php
$output = '';
$result = $modx->db->query( 'SELECT id, pagetitle, joined FROM `Modx_site_content`' );
while( $row = $modx->db->getRow( $result ) ) {
$output .= '<br /> ID: ' . $row['id'] . '<br /> Name: ' . $row['pagetitle'] . '<br /> Joined: ' . $row['joined']
. '<br />---------<br />';
}
echo $output;
?>
but when i try to execute it:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - Table 'isola2.Modx_site_content' doesn't exist »
SQL: SELECT id, pagetitle, joined FROM `Modx_site_content`
[Copy SQL to ClipBoard]
(My db is named isola2)... Any help for me?
thx
"Destiny is not a matter of chance, it's a matter of choice"