User Profile

User
 Siegfried
Location
 Munich, Germany
Time Zone
 (GMT 1): Austria, Belgium, Cameroon, France, Germany, Italy, Spain
URL
 http://cakery.de
Bio
 Blogging about CakePHP in German on my site. Using CakePHP for more than 2 years now and open for requests.

Recent Articles

cakeinfo() helper for cakePHP

As a newbie in cakePHP it is often hard to get all the constants right and not always easy to recognise, what is already defined in the cakePHP core of constants.
  • Published by Siegfried 03/13/07 - 13:21
  • 9498 views
  • 1 comment

Recent Comments

Posted 04/05/2009 10:44am
Hi:

I've followed the code (modified database.php, create the model and place the file csv_source.php in app/models/datasources) but i receive a error message:

" Error: Database table prices for model Price was not found."

Where have I to place the prices.csv file?

Thanks!

Take a look at the connect() in the code. There you can see how the path is constructed. There is also a debug statement, which you can uncomment to show you the exact path on your server.
Posted 05/02/2009 04:26am
I got this working but it seems that I can only get the full dataset. If I try to give a condition to the find(), I still get the full dataset. The same is true with the order parameter in the find():

As I have written in the docs above the code, only a few options are handled at the moment. They are:
  • fields
  • limit
  • page

Conditions is one thing I want to add in the future, which should not be to hard. But "order by" does not make a lot of sense, cause in CSV you have no index like in a database. As you know CSV-files are just flat text files.
Posted 21/01/2009 04:34am
With the new version of CakePHP 1.2.1.8004 (maybe also before) makes the bugfix of comment #20 obsolete.
So this is the right version again for all who have changed the behavior according to comment #20

    function __getContent($file) {
        return $file['type'];
    }

Posted 28/02/2008 11:41am
Great component. In using it, I have found, that there is no way to change the steps, while the wizard is running.

So I implemented a small extension and now it is easy to change the steps in the process function like this:

function processstep1()
{
if ($this->flag1 > 0) {
$this->Wizard->setsteps($this->steps);
return true;
} else if ($this->flag1 == -1) {
$this->Wizard->setsteps(array('step1', 'stepx'));
return true;
}
// exit();
return false;
}

the setsteps is a new function in the wizard:

function setsteps($steps = null)
{
$this->Session->write($this->sessionKey.".Way", $steps);
$this->steps = $steps;
}

and in the Wizard::process there is also a small new part. Search for the "elseif(!is_null($step))" position and change to:

} elseif(!is_null($step)) {
// ---this is new--------- get the steps
if ($this->Session->check($this->sessionKey.".Way")) {
$this->steps = $this->Session->read($this->sessionKey.".Way");
}
// ---end of this is new---------

Hope this is a little help to someone.

Posted 09/05/2007 07:10am
First let me note, that this is the first example, that made me think and look more into behaviors and I like it a lot.

I have one enhancement to note. If you have some logic, that involves for example a $model->saveField() in the rest of your programm, then the _parseTag function can not work, because in $model->data is only one field. So just before the _parseTag call I have included this line of code:


if (array_key_exists($this->settings[$model->name]['table_label'], $model->data[$model->name])) {
So _parseTag will only be called if the table_label field is in the current data of the model.