On Jun 23, 2006, at 3:35 PM, Luke wrote:

>
> I'm still having a hard time... can anybody post an example of a
> "directory-manipulating function" that is built into the model? I have
> tried many of the functions in the API meant to deal with functions,
> and I just can't seem to get them to work.

You won't be using the API, because the Cake Model is meant for  
databases. You need to write your own functions that do the data  
manipulation you're after.

Off the cuff:

<?php

class Something extends AppModel
{
     var $useTable = false;

     function readDirectory($path)
     {
         $d = dir($path);
         $out['Handle'] =  $d->handle;
         $out['Path'] =  $d->path;
         while (false !== ($entry = $d->read())) {
             $out['Entries'][] = $entry;
         }
         $d->close();
         return $out;
     }
}

?>

This might be an example of a function you might use (taken from the  
example at http://us3.php.net/manual/en/class.dir.php) in a model.

You would use this in your controller doing something like

<?php

class SomethingsController extends AppController
{
     function index()
     {
         $this->set('home', $this->Something->readDirectory('/home/ 
billy'));
     }
}

?>

At which point the array you're creating in Somthing::readDirectory()  
would be handed to the view.

-- J

>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to