(I am using MOdx 2.2.0 (revo))
I think I close to the solution, but I am sorry, this is still not clear yet.
// Box is a table?
$c = $xpdo->newQuery('Box');
// BowOwner is the second table to join?
$c->innerJoin('BoxOwner','Owner');
$c->where(array(
'width' => 5,
'Owner.user' => 2,
));
$c->sortby('name','ASC');
$c->limit(5);
// What's Box here
$boxes = $xpdo->getCollection('Box',$c);
I am a bit confused.
By the way, I found that solution:
// Extartait id de l'user
$user = $modx->getObject('modUser', array('username'=>$logUser));
$user->get('id');
// Extrait les documents protégés mais dont il est autorisé
$sql = "SELECT mg.user_group, mg.member, dg.document_group, dg.document FROM modx_member_groups mg, modx_document_groups dg WHERE mg.user_group = dg.document_group AND mg.member = {$user->get('id')}";
if ($stmt = $modx->prepare($sql) AND $stmt->execute() AND $result = $stmt->fetchAll(PDO::FETCH_ASSOC)){
foreach($result as $key => $val){
array_push($docProtectedShow,$val['document']);
// $docProtected = id Document protégé et autorisé pour l'user
}
}
It works, but I would like to code 100% Modx, then to use newQuery
May I ask you and help to have the equilavent with newQuery()?
I have another question
I found this : $obj = $modx->getObject('modDocument', array('id'=>$id))
to get data for resource.
// Stock dans $obj les infos sur le document enfant
$obj = $modx->getObject('modDocument', array('id'=>$id));
// Si le document est publié, le menu pas caché, pas effacé, retient le et continue
if($obj->get('published') == 1 AND $obj->get('hidemenu') == 0 AND $obj->get('delete') == 0){
In my code I noticed that if we are not loggin, $obj = $modx->getObject('modDocument', array('id'=>$id)); can not retrieve resource data on protected resource
(
http://rtfm.modx.com/display/revolution20/Making+Member-Only+Pages)
With $obj = $modx->getObject(), is there an easy way to "say":
If resources are protected => do nothing
if there are not => retrive info
Many thanks for your help, I creating my first snipest ad I learn a lot

)