Re: Exporting large amount of data from cake application
OK, Sorry I didn explain myself well enough, Te point is, one problem wuth Cake for large resultset from queries is that cake is retrieving all data into memory at once; the dataset described in the article allows you to retrieve *one record at a time* from the dataset, then instead of writing a report as in the article, export the data into an XML, Excel or warever you need to do. It just an idea but, who knows? You may end with an interesting exporter pluging. Regards On Wed, Mar 10, 2010 at 4:22 AM, barduck wrote: > That's an interesting article that contains some useful information. > However, I don't think it directly applies to my problem. > > I think that the techniques described in the article are best suited > for situations when you have large amounts of complex data that you > need to be able to display different views of in a flexible manner. > The extracted data is stored back into the database and it is > presented to the user in the traditional ways of using find() and > passing the info to the [buffered] views. > > In my case, the data I need to export is already simplified and the > query is optimized. I don't need to further simplify it or store it > back to the DB. My problem is how to stream this data directly to the > client. If I use find() on the entire data, I run into memory issues > (mostly because everything is buffered in memory until the data is > ready and the overhead of passing the arrays back and forth). If I > split the query into multiple pages and call find on subsets of the > data, the request becomes too slow (the times of the paged queries add > up pretty quickly). > > I need to execute the query and then iterate over the raw result set > and stream/flush the data. I know I can do this all manually but I was > hoping I could leverage cake's models and query building abilities > instead of doing it all from scratch. > > Regards > - barduck > > On Mar 9, 5:49 pm, Jorge Horacio Cué Cantú > wrote: > > Hello, > > > > Why don't You take a look at the article "Star schema (OLAP) setup for > > reporting" at the backery. > > It might be used for exporting instead reporting. > > > > The link to the article is > > > > http://bakery.cakephp.org/articles/view/starschema-olap-setup-for-rep... > > > > Please let us know your insights. > > Regards. > > > > On Mon, Mar 8, 2010 at 1:45 PM, barduck wrote: > > > > > Hi, > > > > > In my cake application (1.2, apache, mysql), I need to export a large > > > amount of data (tens of thousands of records or more) in XML format. > > > The query itself is heavy but nothing the application/database > > > shouldn't handle reasonably (it takes ~1-2 seconds to complete the > > > query itself). > > > > > I first tried the naive way of just calling find() and passing the > > > result to an XML view. This, of course, chokes the application pretty > > > quickly and PHP runs out of memory. > > > > > Next I tried "paging" the query internally within one call in my > > > controller, rending each chuck and flushing the output buffer > > > manually. This worked better but it is taking way too long since I now > > > have dozens of queries instead of one, each taking over a second to > > > complete. > > > > > Now I know there must be a way to achieve this since running the same > > > query in phpmyadmin and exporting the result as XML works very well. I > > > guess that in this case I need to somehow bypass some of cake > > > mechanisms, iterate over the result set myself and steam the data to > > > the client. > > > > > But I still want to use some of cake's strengths when possible so I > > > figured I need to do something like this. > > > > > * use cake for the request: routes, controller/action, parse input > > > parameters > > > * use cake models to generate the find query > > > * obtain the SQL query from cake > > > * get the active mysql database connection from cake > > > * execute the query on the raw connection > > > * iterate over the result set, generate the XML elements, sending > > > chucks of data to the client and flushing as needed. > > > > > (when the above works I may save the XML to intermediate file for > > > caching and redirect to that file, using cake's cache to control > > > expiration). > > > > > Does the above make sense or is there any better way to achieve my > > > goal? > > > > > How do I get the raw SQL query for my models
Re: Exporting large amount of data from cake application
Hello, Why don't You take a look at the article "Star schema (OLAP) setup for reporting" at the backery. It might be used for exporting instead reporting. The link to the article is http://bakery.cakephp.org/articles/view/starschema-olap-setup-for-reporting Please let us know your insights. Regards. On Mon, Mar 8, 2010 at 1:45 PM, barduck wrote: > > Hi, > > In my cake application (1.2, apache, mysql), I need to export a large > amount of data (tens of thousands of records or more) in XML format. > The query itself is heavy but nothing the application/database > shouldn't handle reasonably (it takes ~1-2 seconds to complete the > query itself). > > I first tried the naive way of just calling find() and passing the > result to an XML view. This, of course, chokes the application pretty > quickly and PHP runs out of memory. > > Next I tried "paging" the query internally within one call in my > controller, rending each chuck and flushing the output buffer > manually. This worked better but it is taking way too long since I now > have dozens of queries instead of one, each taking over a second to > complete. > > Now I know there must be a way to achieve this since running the same > query in phpmyadmin and exporting the result as XML works very well. I > guess that in this case I need to somehow bypass some of cake > mechanisms, iterate over the result set myself and steam the data to > the client. > > But I still want to use some of cake's strengths when possible so I > figured I need to do something like this. > > * use cake for the request: routes, controller/action, parse input > parameters > * use cake models to generate the find query > * obtain the SQL query from cake > * get the active mysql database connection from cake > * execute the query on the raw connection > * iterate over the result set, generate the XML elements, sending > chucks of data to the client and flushing as needed. > > (when the above works I may save the XML to intermediate file for > caching and redirect to that file, using cake's cache to control > expiration). > > Does the above make sense or is there any better way to achieve my > goal? > > How do I get the raw SQL query for my models without executing it? > How do I get the database connection? > > Any help is appreciated. > > Thanks! > > - barduck > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Fatal Error: Out of memory error
Bether, You can increase the memory limit in a per action basis using the following function: ini_set('memory_limit', '*256M*'); This can be in your action function, so the memory limit is set just in the functions that require this increase memory usage and let as default all other actions. For example I have an _export() function in my app_controller that allow me to export the result of a find() to an Excel file, and in this case I set the memory limit just before creating the Excel class. I works well. Of course the value (256M in the example) is up to You, check the PHP documentation for the memory_limit setting. Regard. 2009/11/26 Braindead > I got the same error while creating an Excel file with many rows and > columns. So I guess the error is related to processing to much data. > You can either increase the memory limit or decrease the amount of > data to process. > > Hope that helps. > Markus > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: executing queries from a .sql file in the console
Other difference, I am using the $dataSource->_execute() inside a Controller, I untherstand You want to use it inside a Shell. Is this correct?, Is there a difference in environment? Regards. El 14 de octubre de 2009 09:27, Yuncong Zhang escribió: > Thank you Jorge, > > The syntax is correct. Maybe there are no public properties in that class. > > I worked it out, using cakephp fetchResult() function. > > Yuncong > > 2009/10/14 Jorge Horacio Cué Cantú > > Hello $dataSource->_execute($sql) calls the untherlying database driver. >> for example for mysqli it calls mysqli_query(). >> >> IMHO should check the mysqli documentation to check the return value. >> >> BTW, if there is any sintax error in the SQL statement, then the function >> normally returns false, are You shure the SQL statement is complete when >> sent to _execute method?. >> >> Regards. >> >> El 13 de octubre de 2009 14:02, blah escribió: >> >>> Hello Jorge, >>> >>> I meet similar problem. When I try your method, the console shows >>> empty mysqli_result Object for any results no matter what SQL I put in >>> $sql_statement. Do you know why? >>> >>> mysqli_result Object >>> ( >>> ) >>> >>> Thank you in advance. >>> >>> Yc Zhang >>> >>> On Sep 24, 5:43 pm, Jorge Horacio Cué Cantú >>> wrote: >>> > Hello, >>> > >>> > I had a similar problem. I have an Install controller that executes a >>> SQL >>> > script in ordert to create the database. >>> > What I have done is somethjing similar to: >>> > >>> > uses('model'.DS.'connection_manager'); >>> > $db = ConnectionManager::getInstance(); >>> > $dataSource = $db->getDataSource('default'); >>> > >>> > // The to execute each SQL statement do: >>> > >>> > $result = $dataSource->_execute($sql_statement'); >>> > if ($result) { >>> > // success >>> > >>> > } else { >>> > // failure >>> > } >>> > >>> > I hope this helps you. Regards >>> > >>> > 2009/9/24 Stinkbug >>> > >>> > >>> > >>> > > I'm somewhat familiar with the schema stuff. However, the .sql file >>> > > is a file that's going to be provided to us and not a file that will >>> > > be generated by cake. Our .sql file isn't just about the schema, it >>> > > could be large amounts of data manipulation using sql. So unless the >>> > > schema stuff will execute a .sql file (rather than just generate it). >>> > > I don't think it will work for us. That's why I was trying to get >>> the >>> > > code above to work. >>> > >>> > > Any other thoughts? >>> > >>> > > On Sep 23, 4:39 pm, Sam Sherlock wrote: >>> > > > I think you want to create a schemahttp:// >>> > > book.cakephp.org/view/735/Generating-and-using-Schema-files >>> > > > - S >>> > >>> > > > 2009/9/23 Stinkbug >>> > >>> > > > > I'm trying to execute a bunch of sql from a .sql file from the >>> > > > > console. I was trying to use the query method inside the Model >>> class, >>> > > > > but I keep getting the following error. >>> > >>> > > > > Error: Missing database table 'models' for model 'Model' >>> > >>> > > > > Below is my code: >>> > >>> > > > > >> > > > > App::import('Core', array('Model')); >>> > > > > class UpgradeShell extends Shell { >>> > > > >var $uses = array(); >>> > >>> > > > >function main() { >>> > > > >$filename = APP . 'config/sql/upgrade.sql'; >>> > > > >if (file_exists($filename)) { >>> > > > >$handle = fopen($filename, "r"); >>> > > > >$sql = fread($handle, >>> filesize($filename)); >>> > > > >fclose($handle); >>> > > > >echo $sql; >>> > > > >if ($sql) { >>> > > > >//Model::query($sql); >>> > > > >$model = new Model(); >>> > > > >//$model->query($sql); >>> > > > >} >>> > > > >} >>> > > > >} >>> > >>> > > > > } >>> > > > > ?> >>> > >>> > > > > When I try Model::query($sql); >>> > >>> > > > > I get the following error: >>> > > > > Notice: Undefined property: UpgradeShell::$Model in C:\wamp\www\ >>> rx.com >>> > > > > \app\vendors\shells\upgrade.php on line 13 >>> > >>> > > > > Fatal error: Call to a member function query() on a non-object in >>> C: >>> > > > > \wamp\www\rx.com\app\vendors\shells\upgrade.php on line 13 >>> > >>> > > > > I don't really need to specify models, I just want to execute the >>> > > > > queries inside the .sql 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help on pagination.
Hello, I need to paginate the following select. select companies.name, purchase_orders.id, numero_orden_compra, numero_contrato, codigo_producto, codigo_modelo, purchase_orders.created from purchase_orders join contracts on contracts.id = purchase_orders.contract_id join companies on companies.id = contracts.company_id where status_id = 10 order by (select max(purchase_orders.created) from purchase_orders where purchase_orders.contract_id = contracts.id and purchase_orders.status_id = 10), codigo_producto, purchase_orders.created My problem is I don´t know how to paginate this. Please help me. Regards --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: executing queries from a .sql file in the console
Hello, I had a similar problem. I have an Install controller that executes a SQL script in ordert to create the database. What I have done is somethjing similar to: uses('model'.DS.'connection_manager'); $db = ConnectionManager::getInstance(); $dataSource = $db->getDataSource('default'); // The to execute each SQL statement do: $result = $dataSource->_execute($sql_statement'); if ($result) { // success } else { // failure } I hope this helps you. Regards 2009/9/24 Stinkbug > > I'm somewhat familiar with the schema stuff. However, the .sql file > is a file that's going to be provided to us and not a file that will > be generated by cake. Our .sql file isn't just about the schema, it > could be large amounts of data manipulation using sql. So unless the > schema stuff will execute a .sql file (rather than just generate it). > I don't think it will work for us. That's why I was trying to get the > code above to work. > > Any other thoughts? > > On Sep 23, 4:39 pm, Sam Sherlock wrote: > > I think you want to create a schemahttp:// > book.cakephp.org/view/735/Generating-and-using-Schema-files > > - S > > > > 2009/9/23 Stinkbug > > > > > > > > > I'm trying to execute a bunch of sql from a .sql file from the > > > console. I was trying to use the query method inside the Model class, > > > but I keep getting the following error. > > > > > Error: Missing database table 'models' for model 'Model' > > > > > Below is my code: > > > > > > > App::import('Core', array('Model')); > > > class UpgradeShell extends Shell { > > >var $uses = array(); > > > > >function main() { > > >$filename = APP . 'config/sql/upgrade.sql'; > > >if (file_exists($filename)) { > > >$handle = fopen($filename, "r"); > > >$sql = fread($handle, filesize($filename)); > > >fclose($handle); > > >echo $sql; > > >if ($sql) { > > >//Model::query($sql); > > >$model = new Model(); > > >//$model->query($sql); > > >} > > >} > > >} > > > > > } > > > ?> > > > > > When I try Model::query($sql); > > > > > I get the following error: > > > Notice: Undefined property: UpgradeShell::$Model in C:\wamp\www\rx.com > > > \app\vendors\shells\upgrade.php on line 13 > > > > > Fatal error: Call to a member function query() on a non-object in C: > > > \wamp\www\rx.com\app\vendors\shells\upgrade.php on line 13 > > > > > I don't really need to specify models, I just want to execute the > > > queries inside the .sql 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Choose which database to usa, on the fly
Hello, One approach I take with an application is: Each different "customer" (I am developping a SaaS site) o "company" in Your case, can have an specific domain ( www.company1.com, www.company2.com, ...) then based on domain the application can select an specific database. Check following artile in the backery; http://bakery.cakephp.org/articles/view/one-core-one-app-multiple-domains That way you can select even more things, such as: "themes", "database", "AC/ACO", modules..." I hope this can help You. Regards. 2009/9/23 WebbedIT > > Your query is off topic so really needs it's own topic. > > I'm sure you could probably do this, but not sure if it is the right > way to go. > > Why would you separate different companies into different databases? > I would imagine each database would have duplicate tables/models etc. > so simply having a company_id foreignKey within each model would allow > you to pull the relevant data without having to maintain multiple > databases and their connections. > > I have done this with a centrally hosted CMS which drives around 20 > completely different websites from one database, and I am currently > working on a portal/community website for the third sector where any > number of non-profit organisations can manage their own sub-sites. > > Paul. > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Install app
Hello, I need to create an Install process for my application. In some point during the intallation process I need to create the database.php file and check if the cake is able to connect to the database. The code to create the database.php file is: $driver = $this->data['Database']['driver']; $host = $this->data['Database']['host']; $database = $this->data['Database'['database']; $login = $this->data['Database']['login']; $password = $this->data['Database']['password']; $configFile = CONFIGS.'database.php'; $fp = fopen($configFilem, 'w'); fputs('$fp, ""); uses('model'.DS'.'connection_manager'); $ok = ConnectionManager::loadDataSource('default'); if ($ok === null) { $this->Session->setFlash('Cannot los data source'); unlink($configFile); return false; } $db = ConncetionManager::getInstance(); $dataSource = $db->getDataSource('default'); $canConnect = $dataSource->isConnected(); if (!$canConnect) { $this->Session->setFlash('Cannot connect to Database'); unlink($configFile); } return $canConnect; The problem is: I allways get the 'Cannot load data source message'. Is the loadDataSource call ok, pleas help. Thanks --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Problem with Pagination.
Hello, Thanks problem solved! It was a problem with the PuchaseOrders hasMany Equipment configuration: 1: The PuchaseOrders hasMany Equipment was configured in the belongsTo part inside the PuchaseOrders model. 2: The foreignKey element in the PuchaseOrder hasMany Equipment was on a wrong field. Once I fixed the everything worked fine. Thanks. 2009/8/17 brian > Odd. Can you set debug = 2 and post Cake's query? > > You don't have any afterFind() stuff happening? > > 2009/8/17 Jorge Horacio Cué Cantú : > > Hello, > > > > I am having a strange behavior using pagination with Cake 1.2.3.8166 and > > Cake 1.2.4.8284 > > > > I defined the $paginate variable in the controller as: > > > > var $paginate = array( > > 'PurchaseOrder' => array( > > 'limit' => 20, > > 'conditions' => array('PurchaseOrder.status_id' => 14), > > 'contain' => array( > > 'Contract', > > 'Equipment' => array( > > 'fields' => array('id', 'status', 'numero_serie'), > > 'conditions' => array('Equipment.status' => 1) > > ) > > ), > > 'order' => array( > > 'Contract.created' => 'ASC', > > 'PurchaseOrder.id' => 'ASC' > > ) > > ) > > ); > > > > Of course PurchaseOrders belongsTo Contract, and PurchaseOrdes hasMany > > Equipment, the problem is, in index method: > > > > $orders = $this->paginate('PurchaseOrder'); > > > > The problem s that in $orderd array the Equipment is shifted one record > > ahead of the PurchaseOrder that corresponds to, so the Equipment for > record > > [0] is null, then the Equipment in record [1] is the one should be in > record > > [0] and so on, the last Equipment is missing. Because business rules, > every > > PurchaseOrder with status_id 14 has one and only one Equipment with > status = > > 1. > > > > If I check the database with SELECT statements, in there all is OK. > > > > Am I doing something grong?, Please help. > > > > Regards. > > > > > > > > > > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Problem with Pagination.
Hello, I am having a strange behavior using pagination with Cake 1.2.3.8166 and Cake 1.2.4.8284 I defined the $paginate variable in the controller as: var $paginate = array( 'PurchaseOrder' => array( 'limit' => 20, 'conditions' => array('PurchaseOrder.status_id' => 14), 'contain' => array( 'Contract', 'Equipment' => array( 'fields' => array('id', 'status', 'numero_serie'), 'conditions' => array('Equipment.status' => 1) ) ), 'order' => array( 'Contract.created' => 'ASC', 'PurchaseOrder.id' => 'ASC' ) ) ); Of course PurchaseOrders belongsTo Contract, and PurchaseOrdes hasMany Equipment, the problem is, in index method: $orders = $this->paginate('PurchaseOrder'); The problem s that in $orderd array the Equipment is shifted one record ahead of the PurchaseOrder that corresponds to, so the Equipment for record [0] is null, then the Equipment in record [1] is the one should be in record [0] and so on, the last Equipment is missing. Because business rules, every PurchaseOrder with status_id 14 has one and only one Equipment with status = 1. If I check the database with SELECT statements, in there all is OK. Am I doing something grong?, Please help. Regards. --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: After moving from windows to Ubuntu, getting Missing View error
Wel, not exactly. I have Cake in Ubunto 9.04, and it works well. I have some questions: Make shure the web server You are using does have access to all your application, cake and vendors tree. - You can ensure this with the following commands: - sudo find -type d -exec chmod 755 {} + ; - sudo find -type f -exec chmod 644 {} + ; - sudo find -type d -exec chmod 755 {} + ; - sudo find -type f -exec 644 {} + ; - sudo find /tmp -type d -exec chmod 777 {} + ; - sudo find /tmp -type f -exec chmod 666 {} + ; Also make shure all file names are lowercase, including the extension. Regards. 2009/7/14 GravyFace > > Also check your permissions; www-data needs at least read permissions > on your files/directories, but check the Linux installation guide for > CakePHP (you'll need to grant rw to the tmp directory, etc.). > > On Tue, Jul 14, 2009 at 11:08 AM, MrMeikel wrote: > > > > Not very experienced with Linux. But my first guess would be that > > Linux uses case-sensitive file names - check all your views to make > > sure they are correctly cased (I do not know what the correct casing > > is in this situtation). > > > > On Jul 14, 8:24 am, Prabu wrote: > >> Hi, > >> > >> I just moved my cake app folder from windows to ubuntu and getting > >> this error : missing view (could not find .ctp) > >> > >> In my controller I have two methods like this: > >> > >> function foo1($viewtype = null) { > >> // loads data here... > >> $this->render($viewtype, 'ajax'); > >> } > >> > >> function foo2() { > >> $this->Session->write('abcd', "\\"); > >> $this->foo1(); > >> } > >> > >> when I call gohome it throws the MissingView error. > >> > >> It was working correctly in windows. > >> > >> Anyone faced such problem? > > > > > > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Auth->authenticate in beforeFilter causes Auth issues
You can set the salt to an empty strung, too. Regards 2009/6/27 Justin Poliey > > That's where I got the information I'm using now. The problem is if I > just change the hash function with Security::setHash, Cake will still > apply the salt before it hashes the passwords, so the hashes will > still be incompatible. > > Thanks > Justin > > On Jun 27, 7:06 am, John Andersen wrote: > > I understand that you are using MD5 instead of SHA1 in your user > > model! > > > > If that is the final decision, then why don't you just tell CakePHP to > > use MD5 as default and as shown in the example at: > > > > http://book.cakephp.org/view/566/Change-Hash-Function > > > > Maybe that would help you! > > Enjoy, > >John > > > > On Jun 27, 10:37 am, Justin Poliey wrote: > > > > > Right now I'm using Cake's Auth component to build a simple user > > > system. Pastes of the files in their entirety are availablehttp:// > gist.github.com/136935forreference. > > > > > The problem is that when I call: $this->Auth->authenticate = > > > ClassRegistry::init('User'), login.ctp always shows "Login failed. > > > Invalid username or password." even when I haven't submitted anything. > > > If I uncomment that line (line 10, users_controller.php) the message > > > is suppressed but the login logic doesn't work, because it needs the > > > hashedPasswords function in the User model to get the proper password > > > hash. We need to use plain md5 hashes instead of Cake's regular hash > > > because before converting to Cake all of our users just had plain md5 > > > hashed passwords. > > > > > The strangest thing is that this happened before, and was solved by > > > getting rid of all the relevant code, and then completely rewriting > > > it. After the rewrite, it worked for a while, and then I must have > > > done something to break it again. Can anyone see what is wrong? Am I > > > doing something dumb and just not realizing it? > > > > > Thanks for any help. > > > > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Connecting to web services
Hi, Have You trythe class HttpSocket? (see: http://api.cakephp.org/class/http-socket) Regards. 2009/6/26 Turgs > > Hi > > Thanks for you help. > > The service I'm connecting to uses REST rather than SOAP requests and > returns either XML or JSON. > Is there a "cake" way to connect to REST services? > > And where would I make that call? Within each controller so I have > requests scattered throughout my app, or can I have all the REST calls > centralised somewhere? > > Cheers > Turgs > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Connecting to web services
Hello, What I have done is as simple as: $soap = new SoapClient('http://api.example.com/wsdl', array( 'soap_version' => SOAP_1_1, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5, 'exceptions' => false, 'cache_wsdl' => WSDL_CACHE_BOTH, 'user_agent' => 'Example agent', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS ) ); $param->data = 'm...@test.com'; $response = $soap->suscriberAdd($param); SoapClient is an standard PHP function. Regards. 2009/6/25 Turgs > > Hello > > Within a few different controllers, I need to connect to a web service > using a URL similar to: > http://api.example.com/?command=Subscriber.Add&data...@test.com > > What's the appropriate "cake way" to do this in a way it can be called > from different controllers? > I don't think it should be in it's own model, but I don't know know > else. > > Kind regards > Turgs > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Populate last_login field while using Auth-redirect!
Hello Use $this->redirect($this->Auth->redirect()); Instead of $this->redirect('/') > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: cakephp on ubuntu 9.04, php5
ok, Open a Terminal window ( Applications > Accessories > Terminal ) cd CAKE_ROOT/cake/console chmod +x cake where CAKE_ROOT is the directory where you unpacked cake in my case: ~/opt/cake Also to make cake available to the shell, use : cd mkdir bin cd bin ln -s ~/opt/cake/cake/console/cake cake Then close the Terminal, logout a login again so ~/bin is in your $PATH Once You login open a new Terminal window an you will have available the cake command. 2009/6/9 Saliem > > i'd like to use the cake bake command: > > cd cake/console > ./cake bake > > but i get: > > -bash: ./cake: Permission denied > > from what i've looked up - it sounds like i can also run cake bake > from the apps directory. is that actually possible - or do i need to > install something more? > > also - it looks like i might have to add a $PATH environment variable. > i've located my php path as > > /usr/bin/php5 > > and my console path as > > /var/www/cake/console > > i'm stuck here. does anyone have any pointers on what i could do next > so i can use the bake command ? > > -- Saliem > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: List leafs in Tree Behavior
Thanks It works great!. 2009/5/31 delocalizer > > or: > TreeModel->query('SELECT * FROM model_things WHERE model_things + 1 = > model_things.rght'). > 'TreeModel' is obviously the name of your model that behaves as Tree > and 'model_things' is its db table. > > On May 31, 8:42 am, Jorge Horacio Cué Cantú > wrote: > > Hello, > > > > I have a system with a Model behaving as Tree, the question is. > > I need to get a list of rows with out children meaning records that are > > leafs in the tree. > > Is there a way to accomplish that? > > > > Of course It is the "brute force method", but since the tree might be > very > > large, I rather have a most efficient way. > > > > Thanks. > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
List leafs in Tree Behavior
Hello, I have a system with a Model behaving as Tree, the question is. I need to get a list of rows with out children meaning records that are leafs in the tree. Is there a way to accomplish that? Of course It is the "brute force method", but since the tree might be very large, I rather have a most efficient way. Thanks. --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: login voodoo
Your wellcome, sorry for the small mistake. 2009/4/9 brian > > 2009/4/9 Jorge Horacio Cué Cantú : > > Hello, > > > > > > Set > > > > $this->Auth->redirect = false > > > > in AppController::beforeFilter(). > > > > The the login() action will be called after a successful login. > > > > Thanks, that's it (sort of). The var is actually $this->Auth->autoRedirect. > > So, for the record: > > AppController: > function beforeFilter() > { >$this->Auth->fields = array('username' => 'email', 'password' => > 'password'); >$this->Auth->loginError = 'No matching user found.'; >$this->Auth->loginAction = array('controller' => 'users', 'action' > => 'login'); >$this->Auth->loginRedirect = array('controller' => 'pages', 'action' > => 'display', 'home'); > $this->Auth->autoRedirect = false; > $this->Auth->logoutRedirect = array('controller' => 'users', > 'action' > => 'login'); > > if (isset($this->params['admin']) && $this->params['admin']) >{ >$this->layout = 'admin'; >} > } > > > UsersController: > public function login() > { >if ($user = $this->Auth->user()) >{ >$this->User->id = $user['User']['id']; >$this->User->saveField('last_login', date('Y-m-d H:i:s')); > >if (!$user['User']['eula_accepted']) >{ >$this->redirect( > array('controller' => 'users', 'action' => > 'eula') >); >} > $this->redirect($this->Auth->loginRedirect); >} > } > > public function eula() > { >if (!empty($this->data) && $this->data['User']['eula_accepted']) >{ >$this->User->id = $this->Auth->user('id'); >$this->User->saveField('eula_accepted', 1); >$this->Session->write('Auth.User.eula_accepted', 1); > >$this->redirect( > array('controller' => 'pages', 'action' => > 'display', 'home') > ); >} > } > > Thanks again, Jorge! > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: login voodoo
Hello, Set $this->Auth->redirect = false in AppController::beforeFilter(). The the login() action will be called after a successful login. Regards. 2009/4/9 brian > > Actually, yes, I did consider that and I think I will do it that way. > But that still leaves with this problem: how to check this field after > a successful login? > > On Thu, Apr 9, 2009 at 11:48 AM, Angry Coder wrote: > > > > Have you considered a separate column in your users table of > > "accepted_eula" or "eula_version_accepted" if you want to track which > > version of the EULA they have accepted? > > > > It would be easy then to force users to re-accept if it changes and > > you do not have to lose the "last_login" data if you wish to force a > > re-acceptance. > > > > Just thinking out loud here... > > > > > > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: is it a defect of Auth component?
HI, In my application I had to adjust the User information aboard the session, mi solution is as follows: 1. In the AppController set autoRedirect to false: class AppController ... { ... function beforeFilter() { ... $this->Auth->autoRedirect = false; ... } 2. In the UsersController::login action adjust the Session information as follows: class UsersController ... { ... function login() { if (! empty($this->data)) { if ($this->Auth->user()) { // Successful login? $this->_adjustSessionInfo(); } } } 3.- In UsersController::_adjustSessionInfo you can set o delete any information you want from the Session, class UsersController ... { ... function __adjustSessionInfo() { $session = $this->Auth->user(); // Add or remove any $key you want to $session['User] // Removing 'created' key unset($session['User']['created']); // Adding 'fullName' $session['User']['full_name'] = $fullName; ... // IMPORTANT: Preparing to save information. $session = $session['User']; // Saving information $this->Session->del($this->Auth->sessionKey); $this->Session->write($this->Auth->sessionKey, $session); } } Regards. 2009/3/13 ShuXun Liu > hi,all Is there any way to pre-define the fields of users model in Auth > component as it control the login action automatically. >By default , Auth retrieves all the fields in the user model, and save > it into session. >i think it's not necessary and will burden session's job . > >For example, i just want to requery and save two fields' > data(username,city_id) of user model when login. >How can i do it? Should i create my own auth component? >i check the auth.php, It's not easy to change or extend it. > > Please help me , thanks... > > . > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Info from Auth
Hello, I hava a similar problem, From mi actual code I extract this sample adjust the Session content whenever I need more nformation, for example: 1 ) Set class AppController extends Controller { function beforeFilter() { ... $this->Auth->redirect = false; ... } } 2) In UserController::login() include class UserController extends AppController { function login() { if (!$this->data) { $id = $this->Auth->user('id'); if ($id) { // Success login $this->__adjustSessionInfo($id); ... } } } function __adjustSessionInfo($id) { $this->User->contain(array('Group', 'Profile')); $user = $this->User->read(null, $id); $session = $this->Auth->user(); $session['User']['id'] = $id; if (array_key_exists('Profile', $user)) { if (isset($user['Profile']['first_name'])) { $session['User']['first_name'] = $user['Profile']['first_name']; } if (isset($user['profile']['father_last_name'])) { $session['User']['father_last_name'] = $user['Profile']['father_last_name']; } if (isset($user['Profile']['mother_last_name'])) { $session['User']['mother_last_name'] = $user['Profile]['mother_last_name']; } } else { $session['User']['first_name'] = $session['User']['username']; $session['User']['father_last_name'] = 'User'; } $session['User']['name'] = ''; $sep = ''; if (isset($session['User']['first_name'])) { $session['User']['name'] .= $sep.$session['User']['first_name']; $sep = ' '; } if (isset($session['User']['father_last_name'])) { $session['User']['name'] .= $sep.$session['User']['father_last_name']; $sep = ' '; }; if (isset($session['User']['mother_last_name'])) { $session['User']['name'] .= $sep.$session['User']['mother_last_name']; $sep = ' '; } $session['User']['is_super'] = $user['Group']['is_super']; $session['User']['group'] = $user['Group']['title']; $this->Session->del($this->Auth->sessionKey); $session = $session['User']; $this->Session->write($this->Auth->sessionKey, $session); } } In above code I added Profile and Group info to Session. Later on $this->Auth->user($key)will return any $key stored by __adjustSesison() function besides the ones stored by Auth itself. You may also delete any non wanted key. Regards. 2009/3/10 Sergei > > You have to do it by hands, using find() and beforeAction() on some > actions where you need profile info. Auth doesn't get related data. > > On 11 мар, 05:47, "Dave Maharaj :: WidePixels.com" > wrote: > > Does anyone know how to get user variables from the Auth from a different > > Table? > > > > [Auth] => Array > > > > ( > > > > [User] => Array > > > > ( > > > > [id] => 6 > > > > [username] => mary > > > > [email] => > > > > [group_id] => 4 > > > > [created] => 2009-03-10 14:29:45 > > > > [modified] => 2009-03-10 14:29:45 > > > > [last_login] => 2009-03-10 > > > > ) > > > > ) > > > > For example here Mary is User ID 6 she belongs to Group 4 which in this > case > > is a TEACHER so she has a TEACHER profile which has an ID of 3. How can I > > take the Auth id 6 to find her Teacher ID in the TEACHER TABLE? > > Thanks > > Dave > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: cake 1.2 Auth component not logging in
Are you inserting the first user by hand? Try setting the password to the SH1 of the concatenation of the salt and the password you want: $cipher_password = SHA1( $salt . $plain_password ) 2009/3/3 aka > > Thing is that it does seem to work when my salt is empty... As > mentioned before this is a new installation of both cake and the db. > Really maddening!! > > > On 27 feb, 17:00, Xoubaman wrote: > > User table got username and password? > > > > Beforefilter ir correct? > > > > Do you allow the public actions in your controller? > > > > Auth is tricky, but following the tutorial step by step should work. > > > > On Feb 27, 4:40 pm, aka wrote: > > > > > I keep running in to this problem over and over again. > > > > > Whenever I implement the cakephp 1.2 Auth component I can'tlogin(and > > > yes, I'm sure thelogincredentials are right). The password is saved > > > with the sha1 algorithm and the salt value has been changed. New cake > > > installation + a new database (workflow: setting up the db + tables, > > > using the cake console to bake the necessary m/c/v's ) But when ever I > > > try to log in I get the 'Loginfailed. Invalid username or password.' > > > message. > > > > > Really hope someone can help me out here! > > > Thanx > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: What do you develop in (ide, text editor, etc.)?
I switched to Eclipse from Netbeans 6.5 because Netbeans does not handle well accents in Fedora 10. If I could solve this only issue, I would back to Netbeans immediately. 2009/2/28 jitka (poLK) > > I switched from Eclipse 3.4 and PDT2 to Netbeans 6.5 this week as well. > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Doing a NOW() in save().
Hello, I use: *date('Y-m-d H:i:s', time())* instead 'NOW()' and it works fine. Regards. 2009/2/5 Miles J > > I have this method that updates login information on a user. It all > works, except I cant figure out how to get the mysql NOW() to work. > Any ideas? > > function updateLogin($user, $ip) { >$data = array(); >$data['currentIP'] = $ip; >$data['lastLoginTime'] = $user['User']['currentLoginTime']; >$data['currentLoginTime'] = 'NOW()'; > >$this->id = $user['User']['id']; >return $this->save($data, false); > } > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Fatal error: CakePHP core could not be found
Hello, Did you FTP the .htaccess file too? There is some stuff inside tha is needed by CakePHP. Regards. 2009/1/23 Webweave > > It looks like you must have a typo in one of your config files. > > The word "PATH_SEPARATOR" is being placed in your PATH instead of the > path separator charater (:), so there has to be a typo where you are > setting up the include path. > > On Jan 23, 5:42 am, Mono wrote: > > Hello!! > > > > My Cake-App works perfect on my localhost, but after i uploaded it i > > become the error msg: > > > > Warning: Failed opening 'cake/bootstrap.php' for inclusion > > (include_path='/mnt/web2/13/38/51150638/htdocs/plPATH_SEPARATOR/mnt/ > > web2/13/38/51150638/htdocs/pl/app/PATH_SEPARATOR.:') in /mnt/ > > web2/13/38/51150638/htdocs/pl/app/webroot/index.php on line 84 > > > > Fatal error: CakePHP core could not be found. Check the value of > > CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to > > the directory containing your /cake core directory and your /vendors > > root directory. in /mnt/web2/13/38/51150638/htdocs/pl/app/webroot/ > > index.php on line 85 > > > > ...and i dont know why. > > > > if i do a var_dump on the define CAKE_CORE_INCLUDE_PATH in the file > > app/webroot/index.php i get: > > > > string(34) "/mnt/web2/13/38/51150638/htdocs/pl" > > > > ... and that looks ok. The url to my app is:http://cbmono.de/pl/ > > similar as on my localhost:http://localhost/pl/ > > > > Could anyone help me pls? > > > > Best regards! > > claudio. > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: XAMMP for Windows with cakePHP
Hello, Depending on your operating system, for example for Linux: sudo mkdir /opt/lampp/htdocs/myproject sudo cp -r ~/myproject/* /opt/lampp/htdocs/myproject sudo chown -R nobody:nobody /opt/lampp/htdocs/myproject Where myproject is the directory for your project. Do not copy cake directly under htdocs/ because it breaks lampp installation. Or if you are using Windows Just make a directory under C;\xampp\htdocs and copy all your code under it. Either case use http://localhost/myproject to access your application. Regards 2009/1/18 Sharmo > > I am not sure if my first post worked. I am therefore posting again. > > I am using XAMPP for Windows as my localhost server. > > When I try tho view my application after "baking" it. There is no CSS > or images being renered. > > I have tred the forums at both XAMPP and PHPVideotutorials without > success. > > Please help. > > Regards > > Peter > > > > --~--~-~--~~~---~--~~ 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---