Hi There,
I know there's tons of stuff online already about this but I just can't my head around it.
I have a snippet and I want to select all the data in a certain table and return it in an array (which is then outputted as a CSV file)
What's the best way to do this?
I've tried several examples I've found but so far nothing but errors!
Thanks in advance
OK, so changed $xpdo to $modx and that seem to work, now I need to know how to get the data from the $applications array...
-
☆ A M B ☆
- 3,141 Posts
Did set up the xPDO schema and build the model? Did you call $modx->addPackage() to register your custom tables with modX?
If so, try this:
$applications = $modx->getCollection('contact_form', array('downloaded' => NULL));
foreach ($applications as $app) {
var_dump($app->toArray());
}
If it's a single table and already exists, this would be one way to make sure the class and map files are created correctly:
http://bobsguides.com/custom-db-tables.html
Thanks Guys especially Bob, I started again using your tutorial as an example and got it working. I don't know what was wrong with it, what I ended up with was identical to what I started with!
Thanks again.
I'm glad you got it sorted. Thanks for reporting back.