Re: Dynamically change data source of models
I use Ad-hoc joins to LEFT JOIN data from different databases using the same default db config and it works well. Just specify table = 'common_db_name.table_name' . You will obviously need to ensure that the db user specified in your config has at least SELECT privs to both databases. I usually give Any user on localhost SELECT privs on my common database, but you could just as easily grant database specific as well. On Aug 13, 5:11 am, Fritsie steff...@gmail.com wrote: Hello, I'm developing an application which will be used by multiple companies and I want to use a shared database for common information like users, companies, permissions etc, but I want to use a separate database for each company for their own (private) information. The reason to give every company an own database is for speed, security en taking advantage of the caching from the database. I've read the article by Anssi Rajakallio (doze) at the Bakery:http://bakery.cakephp.org/articles/view/use-multiple-databases-in-one... And also the comments of the cakephp team, but I still have a few problems. I don't want to initialize a connection to 1 company-database (the solution of Anssi) at the start, but I want to be able to change from data source while making one request, for instance when I want to benchmark multiple companies I need to make one request, and multiple database requests on different databases (depending on the companies I want to benchmark). The question is how I can change dynamically the data source of all the models who don't use the 'shared' data source. Thanks in advance. Regards, Raymond --~--~-~--~~~---~--~~ 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: Function Find - problem
It would be helpful if you posted the actual code of your find(), but it would appear that you are not forming your conditions array correctly. I haven't had any issues using LIKE, and maybe this link will help : http://book.cakephp.org/view/74/Complex-Find-Conditions .Book.title LIKE = A% should give you the results your looking for. On Aug 11, 5:40 am, boobalan boobal...@gmail.com wrote: i found some difficulties using function find(), / SELECT `Book`.`isbn`, `Book`.`title`, `Book`.`author_name` FROM `books` AS `Book` WHERE `Book`.`title` = 'LIKE 'A%' ORDER BY `Book`.`title` ASC // In this query, i can't retrieve data because the conditions pasted in this query is wrong WHILE using LIKE in a query we can't use '=' symbol so suggest a solution for this. Boobalan.M --~--~-~--~~~---~--~~ 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: Access non CakePHP session from within CakePHP
The $_SESSION array should have what your looking for. On Aug 11, 12:15 am, Fabs lord.f...@gmail.com wrote: G'day all I'm integrating CakePHP into a legacy CMS. The CMS stores all of its session data in the generic php session (it never calls session_name ()). I need to retrieve this session data to prevent requiring users to log in twice to use the old and the new functions. Is there a way to do this? Thanks everyone. --~--~-~--~~~---~--~~ 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: PDF reader in view without new header
Have you tried removing /app/webroot from the $html-url call? Not sure if that will fix all your issues but that is where I would start. On Aug 11, 7:54 am, RugerJ hoogervo...@gmail.com wrote: How can you show a pdf file within a view without setting the header to pdf. I tried to embed it like this: EMBED SRC=?php echo $html-url('/app/webroot/files/userfile/'. $uploads['FileUpload']['subdir'].'/'.$uploads['FileUpload'] ['file_name']);?#toolbar=0statusbar=0messages=0navpanes=0 HEIGHT=450 WIDTH=555 NOEMBED Your browser does not support embedded PDF files. /NOEMBED /EMBED But that doesn't work because of the routing says controller not found. Is there a way around? Thnx in advance --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
It is always a bad idea to try and squeeze lists into a single field. It will inevitably lead to you pulling your hair out in the future. Anyone who is tempted to store comma separated lists in a field because its 'easier' should spend a few minutes reading about database normalization. http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html is a great place to start. Following a few simple 'rules' when developing your tables will save you the headache of trying to write overly complex SELECT queries in the future. On Aug 6, 2:19 am, Rawna asumaw...@gmail.com wrote: How do I store an array into the database? Here's the view: echo $form-input('name'); echo $form-input('bio'); echo $form-input('book_id', array('multiple' = true)); What if I got multiple books? How do I store them in the database? Whenever I tried saving the entry I get these errors: Notice (8): Array to string conversion Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck Palahniuk', 'Great writer', Array) I created the BookController using bake BTW. Thanks in advance! --~--~-~--~~~---~--~~ 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: sql WHERE NOT EXISTS
I am not sure if this is what you are looking for, but wouldn't you get what your looking for (and avoid the subquery) by WHERE'ing roles.id IS NULL? Maybe I am misunderstanding what data you are trying to pull as the where user_id = 3 in the subquery is a bit confusing to me, are you running that query for each user_id ? On Aug 9, 2:46 pm, euromark (munich) dereurom...@googlemail.com wrote: does anybody know if there is a cake function for the WHERE NOT EXISTS functionality? i have users who have many roles in the join table role_users - and i want to display the ones not having any roles yet id user_id role_id 1 2 3 2 3 3 etc (user 1 not in the list yet, so does not have any role) with mysql itself if would say: select * from users left join role_users where not exists (select * from role_users where user_id = 3) for example i could do some complex reversing - but was looking for some more convinient way to do it :) thx, mark --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
AuthComponent using two tables
I have a users table that stores a contact_id as well as a password. I would like AuthComponent to use ['Contact']['email'] for the username field and ['User']['pass'] for passwords. User hasOne Contact. These are the methods I have tried without success: Method #1 - Try and use Contact.email in both Controller View Controller (beforeFilter()): $this-Auth-fields = array('username' = Contact.email,'password' = pass); Login View: echo $form-create('User', array('action' = 'login')); echo $form-input('Contact.email'); echo $form-input('pass',array('type' = 'password')); Result: Returns invalid user/pass error. Debug SQL output shows that no query was sent, simply failing without even querying DB. Method #2 - Try using Contact.email in View but simply email in Controller Controller (beforeFilter()): $this-Auth-fields = array('username' = email,'password' = pass); Login View: echo $form-create('User', array('action' = 'login')); echo $form-input('Contact.email'); echo $form-input('pass',array('type' = 'password')); Result: Same as Method #1, it fails yet still does not generate a query. Method #3 Controller (beforeFilter()): $this-Auth-fields = array('username' = email,'password' = pass); Login View: echo $form-create('User', array('action' = 'login')); echo $form-input('email'); echo $form-input('pass',array('type' = 'password')); Result: This was the only method that actually produced a SQL query. The SQL it generates is mostly correct, LEFT JOIN'ing the contact table to the user table, however it is trying to pull User.email rather than Contact.email , resulting in a MySQL error. It would appear that the underlying issue here is that $this-Auth- fields is unwilling to accept Contact.email. I am not willing to simply move the email field to the users table since storing the same data twice is obviously not good DB design. Is there any way to still use the core AuthComponent with this DB schema? Thanks for the 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 -~--~~~~--~~--~--~---