<object class="myObject" table="pp_category" extends="xPDOSimpleObject">
<field key="name" dbtype="varchar" phptype="string" precision="255" null="false" default="" />
...
</object>
$c = $modx->newQuery('myObject') ; // you query the object (the "class=" in your schema) not the table name
<?xml version="1.0" encoding="UTF-8"?> <model package="pepish" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="Category" table="category" extends="xPDOObject"> <field key="category_id" dbtype="smallint" precision="4" phptype="integer" null="false" index="pk" generated="native" /> <field key="name" dbtype="varchar" precision="64" phptype="string" null="false" /> <field key="name_alt" dbtype="varchar" precision="128" phptype="string" null="false" /> <field key="parent_id" dbtype="smallint" precision="4" phptype="integer" null="true" /> <field key="view" dbtype="smallint" precision="2" phptype="integer" null="false" default="1" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="category_id" length="" collation="A" null="false" /> </index> </object> <object class="Galerie" table="galerie" extends="xPDOObject"> <field key="galerie_id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" /> <field key="title" dbtype="varchar" precision="48" phptype="string" null="false" /> <field key="name_cz" dbtype="varchar" precision="64" phptype="string" null="false" /> <field key="name_lat" dbtype="varchar" precision="64" phptype="string" null="false" /> <field key="kategorie" dbtype="smallint" precision="4" phptype="integer" null="false" /> <field key="kde" dbtype="varchar" precision="64" phptype="string" null="false" /> <field key="kdy" dbtype="date" phptype="date" null="true" /> <field key="upload_date_time" dbtype="timestamp" phptype="timestamp" null="false" default="CURRENT_TIMESTAMP" /> <field key="copyright" dbtype="varchar" precision="32" phptype="string" null="false" /> <field key="permission" dbtype="smallint" precision="2" phptype="integer" null="false" /> <field key="display" dbtype="smallint" precision="2" phptype="integer" null="false" /> <field key="short_text" dbtype="mediumtext" phptype="string" null="true" /> <field key="picture_name" dbtype="varchar" precision="48" phptype="string" null="true" /> <field key="thumbs_name" dbtype="varchar" precision="48" phptype="string" null="true" /> <field key="path_large" dbtype="varchar" precision="64" phptype="string" null="true" /> <field key="path_thumbs" dbtype="varchar" precision="64" phptype="string" null="true" /> <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" > <column key="galerie_id" length="" collation="A" null="false" /> </index> </object> </model>
<?php $xpdo_meta_map = array ( );
if($result){
$c = $modx->newQuery('Category');
$c->sortby('name','ASC');
$pokus = $modx->getCollection('Category',$c);
}
echo '$pokus: '.$pokus.'';
foreach ($pokus as $pok) {
echo $pok->get('name')."\n";
}
<?php
$path = MODX_CORE_PATH . 'components/pepish/';
$result = $modx->addPackage('pepish',$path . 'model/','pp_');
echo '$result: '.$result.'<br>';
echo '$path: '.$path.'<br>';
if($result){
$c = $modx->newQuery('Category');
$c->sortby('name','ASC');
$pokus = $modx->getCollection('Category',$c);
}
echo '$pokus: '.$pokus.'<br>';
echo 'Total: '.count($pokus).'<br>';
foreach ($pokus as $pok) {
echo $pok->get('name')."\n";
}$result: 1
$path: /home/www/puschpull.org/www/modx_rev/core/components/pepish/
$pokus: Array
Total: 0
<?php
require_once (dirname(dirname(__FILE__)) . '/category.class.php');
class Category_mysql extends Category {}<?php
class Galerie extends xPDOObject {}<?php
require_once (dirname(dirname(__FILE__)) . '/category.class.php');
class Category_mysql extends Category {}<?php
$xpdo_meta_map['Category']= array (
'package' => 'pepish',
'version' => '1.1',
'table' => 'category',
'fields' =>
array (
'category_id' => NULL,
'name' => NULL,
'name_alt' => NULL,
'parent_id' => NULL,
'view' => 1,
),
'fieldMeta' =>
array (
'category_id' =>
array (
'dbtype' => 'smallint',
'precision' => '4',
'phptype' => 'integer',
'null' => false,
'index' => 'pk',
'generated' => 'native',
),
'name' =>
array (
'dbtype' => 'varchar',
'precision' => '64',
'phptype' => 'string',
'null' => false,
),
'name_alt' =>
array (
'dbtype' => 'varchar',
'precision' => '128',
'phptype' => 'string',
'null' => false,
),
'parent_id' =>
array (
'dbtype' => 'smallint',
'precision' => '4',
'phptype' => 'integer',
'null' => true,
),
'view' =>
array (
'dbtype' => 'smallint',
'precision' => '2',
'phptype' => 'integer',
'null' => false,
'default' => 1,
),
),
'indexes' =>
array (
'PRIMARY' =>
array (
'alias' => 'PRIMARY',
'primary' => true,
'unique' => true,
'type' => 'BTREE',
'columns' =>
array (
'category_id' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
),
);
<?php
require_once (dirname(dirname(__FILE__)) . '/galerie.class.php');
class Galerie_mysql extends Galerie {}<?php
$xpdo_meta_map['Galerie']= array (
'package' => 'pepish',
'version' => '1.1',
'table' => 'galerie',
'fields' =>
array (
'galerie_id' => NULL,
'title' => NULL,
'name_cz' => NULL,
'name_lat' => NULL,
'kategorie' => NULL,
'kde' => NULL,
'kdy' => NULL,
'upload_date_time' => 'CURRENT_TIMESTAMP',
'copyright' => NULL,
'permission' => NULL,
'display' => NULL,
'short_text' => NULL,
'picture_name' => NULL,
'thumbs_name' => NULL,
'path_large' => NULL,
'path_thumbs' => NULL,
),
'fieldMeta' =>
array (
'galerie_id' =>
array (
'dbtype' => 'int',
'precision' => '10',
'phptype' => 'integer',
'null' => false,
'index' => 'pk',
'generated' => 'native',
),
'title' =>
array (
'dbtype' => 'varchar',
'precision' => '48',
'phptype' => 'string',
'null' => false,
),
'name_cz' =>
array (
'dbtype' => 'varchar',
'precision' => '64',
'phptype' => 'string',
'null' => false,
),
'name_lat' =>
array (
'dbtype' => 'varchar',
'precision' => '64',
'phptype' => 'string',
'null' => false,
),
'kategorie' =>
array (
'dbtype' => 'smallint',
'precision' => '4',
'phptype' => 'integer',
'null' => false,
),
'kde' =>
array (
'dbtype' => 'varchar',
'precision' => '64',
'phptype' => 'string',
'null' => false,
),
'kdy' =>
array (
'dbtype' => 'date',
'phptype' => 'date',
'null' => true,
),
'upload_date_time' =>
array (
'dbtype' => 'timestamp',
'phptype' => 'timestamp',
'null' => false,
'default' => 'CURRENT_TIMESTAMP',
),
'copyright' =>
array (
'dbtype' => 'varchar',
'precision' => '32',
'phptype' => 'string',
'null' => false,
),
'permission' =>
array (
'dbtype' => 'smallint',
'precision' => '2',
'phptype' => 'integer',
'null' => false,
),
'display' =>
array (
'dbtype' => 'smallint',
'precision' => '2',
'phptype' => 'integer',
'null' => false,
),
'short_text' =>
array (
'dbtype' => 'mediumtext',
'phptype' => 'string',
'null' => true,
),
'picture_name' =>
array (
'dbtype' => 'varchar',
'precision' => '48',
'phptype' => 'string',
'null' => true,
),
'thumbs_name' =>
array (
'dbtype' => 'varchar',
'precision' => '48',
'phptype' => 'string',
'null' => true,
),
'path_large' =>
array (
'dbtype' => 'varchar',
'precision' => '64',
'phptype' => 'string',
'null' => true,
),
'path_thumbs' =>
array (
'dbtype' => 'varchar',
'precision' => '64',
'phptype' => 'string',
'null' => true,
),
),
'indexes' =>
array (
'PRIMARY' =>
array (
'alias' => 'PRIMARY',
'primary' => true,
'unique' => true,
'type' => 'BTREE',
'columns' =>
array (
'galerie_id' =>
array (
'length' => '',
'collation' => 'A',
'null' => false,
),
),
),
),
);
<?php
$path = MODX_CORE_PATH . 'components/pepish/';
$result = $modx->addPackage('pepish',$path . 'model/','pp_');
echo '$result: '.$result.'<br>';
echo '$path: '.$path.'<br>';
if($result){
$c = $modx->newQuery('Galerie');
$c->where(array(
'Galerie.name_cz' => 'Šidélko brvonohé',
'Galerie.kde' => 'Průhonice',
));
$c->sortby('galerie_id','ASC');
$pokus = $modx->getCollection('Galerie',$c);
}
echo '$pokus: '.$pokus.'<br>';
echo 'Total: '.count($pokus).'<br>';
foreach ($pokus as $pok) {
echo $pok->get('galerie_id')."\n";
echo $pok->get('name_cz')."\n";
echo $pok->get('name_lat')."\n";
echo $pok->get('kde').'<br>'."\n";
}$result: 1
$path: /home/www/puschpull.org/www/modx_rev/core/components/pepish/
$pokus: Array
Total: 7
34 Šidélko brvonohé (Platycnemis pennipes) Průhonice
35 Šidélko brvonohé (Platycnemis pennipes) Průhonice
36 Šidélko brvonohé (Platycnemis pennipes) Průhonice
37 Šidélko brvonohé (Platycnemis pennipes) Průhonice
38 Šidélko brvonohé (Platycnemis pennipes) Průhonice
39 Šidélko brvonohé (Platycnemis pennipes) Průhonice
43 Šidélko brvonohé (Platycnemis pennipes) Průhonice
<?php
$path = MODX_CORE_PATH . 'components/pepish/';
$result = $modx->addPackage('pepish',$path . 'model/','pp_');
echo '$result: '.$result.'<br>';
echo '$path: '.$path.'<br>';
if($result){
$c = $modx->newQuery('Category');
$c->sortby('category_id','ASC');
$pokus = $modx->getCollection('Category',$c);
}
echo '$pokus: '.$pokus.'<br>';
echo 'Total: '.count($pokus).'<br>';
foreach ($pokus as $pok) {
echo $pok->get('category_id')."\n";
}$result: 1
$path: /home/www/puschpull.org/www/modx_rev/core/components/pepish/
$pokus: Array
Total: 0
$path = MODX_CORE_PATH . 'components/pepish/';
$result = $modx->addPackage('pepish',$path . 'model/','pp_');
echo '$result: '.$result.'';
echo '$path: '.$path.'';
if($result){
$c = $modx->newQuery('Galerie');
$c->where(array(
'Galerie.name_cz' => 'Šidélko brvonohé',
'Galerie.kde' => 'Průhonice',
));
$c->sortby('galerie_id','ASC');
$pokus = $modx->getCollection('Galerie',$c);
}
// echo '$pokus: '.$pokus.'';
// echo 'Total: '.count($pokus).'';
$galid= $pok->get('galerie_id');
$namecz = $pok->get('name_cz');
$namealt = $pok->get('name_lat');
$kde = $pok->get('kde');
$output = ''; // initialize the output
if(count($pokus)>0){ // if there is something to output
//starts the table
$ouptut .= '<table><tr>
<th>id</th>
<th>name</th>
<th>name_alt</th>
<th>parent_id</th>
<th>view</th>
</tr>';
foreach ($pokus as $pok) {
// write each line of the table
$output .= '<tr>
<td>'.$galid.'</td>
<td>'.$namecz.'</td>
<td>'.$namealt.'</td>
<td>'.$kde.'</td></tr>';
}
return $output.'</table>'; // close the table and return it
}