Created
February 8, 2013 13:42
-
-
Save hansek/4739101 to your computer and use it in GitHub Desktop.
Test snippet for xPDO model of Workshops CMP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// inicializace balíčku | |
$path = MODX_CORE_PATH .'components/workshops/'; | |
$result = $modx->addPackage('workshops', $path .'model/', 'cx_'); | |
if (! $result) { | |
return 'Failed to add package'; | |
} | |
else { | |
$output = '<p>Package added</p>'; | |
} | |
// ----------------------------------------------------------------- | |
// Test vložení záznamu | |
// instanciace balíčku pro vytvoření nového záznamu do tabulky cx_workshop | |
$workshop = $modx->newObject('Workshop'); | |
// nastavím hodnoty pro daný záznam | |
$workshop->set('title', 'Testovací záznam'); | |
$workshop->set('description', 'Popisek testovacího záznamu do tabulky.'); | |
// vlastní uložení záznamu do tabulky | |
$workshop->save(); | |
// ----------------------------------------------------------------- | |
// Test načtení záznamů | |
$workshops = $modx->getCollection('Workshop'); | |
$output .= '<p>Celkem: '. count($workshops) . '</p>'; | |
foreach($workshops as $ws) { | |
$output .= '<p>'; | |
$output .= 'Název: '. $ws->get('title') .'<br />'; | |
$output .= 'Popis: '. $ws->get('description'); | |
$output .= '</p>'; | |
} | |
return $output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment