Re: CSV file as DataSource
Seems interesting. Problem is I do not have access to MySQL 5.1(beta). I will have an eye on it though. Alex On Oct 27, 10:38 pm, teknoid <[EMAIL PROTECTED]> wrote: > If you are using MySQL you might consider > this:http://dev.mysql.com/tech-resources/articles/csv-storage-engine.html > > On Oct 27, 12:44 pm, su6z3r0 <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I am trying to setup a csv file as data source. But I do not know how/ > > where I could dynamically change the file name of the csv file. In my > > below example the name "email.csv" should actually be a file name > > which can be set up in the controller. > > > the database.php contains: > > var $csv = array( > > 'datasource' => 'Csv', > > 'file' => 'email.csv' <- this should be a variable file > > name set up in the controller > > ); > > > In my model I connect to the source like this: > > > function csvFindAll() { > > $this->setDataSource('csv'); > > $csv = $this->getDataSource(); > > return $csv->findAll(); > > } > > > the Csv_source.php file opens the file: > > > function connect() { > > $this->File = fopen(WWW_ROOT . 'files/' . $this->config['file'], > > "r"); > > > if (!$this->File) { > > return false; > > }else { > > return true; > > } > > } > > > Any ideas, hints how I could achieve that? > > > TIA, > > Alex > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CSV file as DataSource
Aaarrglll... I was so close... Anyway. It works. You are my hero! Thank's dude. Alex On Oct 28, 4:20 am, ORCC <[EMAIL PROTECTED]> wrote: > Actually, it is (assuming your db configuration variable is called > "default"): > > $conn =& ConnectionManager::getInstance() > $conn->config->default['file'] = 'your_csv_file'; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CSV file as DataSource
Actually, it is (assuming your db configuration variable is called "default"): $conn =& ConnectionManager::getInstance() $conn->config->default['file'] = 'your_csv_file'; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CSV file as DataSource
Use the ConnectionManager::getInstance() method to get the DB Manager instance, and set manually the database. $conn =& ConnectionManager::getInstance() $conn->config['file'] = 'your_csv_file'; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CSV file as DataSource
If you are using MySQL you might consider this: http://dev.mysql.com/tech-resources/articles/csv-storage-engine.html On Oct 27, 12:44 pm, su6z3r0 <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to setup a csv file as data source. But I do not know how/ > where I could dynamically change the file name of the csv file. In my > below example the name "email.csv" should actually be a file name > which can be set up in the controller. > > the database.php contains: > var $csv = array( > 'datasource' => 'Csv', > 'file' => 'email.csv' <- this should be a variable file > name set up in the controller > ); > > In my model I connect to the source like this: > > function csvFindAll() { > $this->setDataSource('csv'); > $csv = $this->getDataSource(); > return $csv->findAll(); > } > > the Csv_source.php file opens the file: > > function connect() { > $this->File = fopen(WWW_ROOT . 'files/' . $this->config['file'], > "r"); > > if (!$this->File) { > return false; > }else { > return true; > } > } > > Any ideas, hints how I could achieve that? > > TIA, > Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---