Re: creating and viewing an image database
JP wrote: > I would like to make an image upload and view database, storing the > images in the file system isn't really practical for my project. care to elaborate why it is not practical to store images on the file system? (in your case of course) Cheers Tarique --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Scaffolding on cake_1.1.6.3264 allowing add and delete but "server dropped reply" on others
Hi, It's my first post so please be nice... I can sucessfully use the $scaffold variable to get add and delete functionality, but view and edit are behaving strangely. I first thought it was a rewrite problem with some kind of recursion going on because the main problem is that (always for Edit, but only sometimes for View) I get dropped server connections and the apache error log shows lines like this: >[Sat Aug 05 17:12:15 2006] [notice] child pid 16518 exit signal Segmentation >fault (11) When View renders a page instead of choking on the dropped server error, it shows an error at the top: Undefined index : data That appears to me to be be a problem with getting the data from MySQL. So, then I began suspecting mysql and I rebuilt the database, reinstalled the latest cake code, followed the tutorial again and got the same Segmentation fault and dropped connection errors. I then tried the several table types that mysql offers MyISAM, ISAM and INNODB all with the same result. Here's my set up: Mac OSX.3 Apache PHP 4.3.6 MySQL 4.0.18 cake_1.1.6.3264 Safari 2.0.4(419.03) Safari tells me this error: Safari can't open the page. Safari can't open the page "http://domain.com/x/urls/view/2/";. The error was: "lost network connection" (NSURLErrorDomain:-1005) Please choose Report Bug to Apple from the Safari menu, note the error number, and describe what you did before you saw this message. When I cross check it from curl I see "curl: (52) Empty reply from server" and Firefox shows me a blank page, so I know it is not a Safari problem. mod_rewrite installed and functioning properly on cake and other php code. I can also move the PHP pretty URLs mode that CakePHP offers and see the same set of errors and odd CRUD behavior. I followed the blog tutorial and modified it to start my own application which is a clone of tinyurl and snurl services but for my own private set of urls. Database created with this SQL: # phpMyAdmin SQL Dump # version 2.5.6 # http://www.phpmyadmin.net # # Table structure for table `urls` # CREATE TABLE `urls` ( `id` int(10) unsigned NOT NULL auto_increment, `linkname` varchar(50) default NULL, `uri` text, `created` datetime default NULL, `modified` datetime default NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_I I've been working on this for quite a while and I feel like it is very close to a breakthrough and I'd appreciate it if anyone could lend me a hand or turn my head toward a good debugging tactic. I've tried peeling away code and inserting print statements but the code base is so large and spread out it is hard for a newbie to really get a handle on it and find exactly where the Edit and View steps are failing in scaffolding. TIA, BakeryBoy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
IMPORTANT CakePHP Security Fix
All CakePHP users,A kind soul informed us that the Not Found error page can be exploited via inserting _javascript_ code in the address bar. This release provides a fix for this vulnerability. This release also includes some other improvements to the bake script and prepares for the day when the controller object is not available in the view. Cakebaker mentioned the addition of the session helper. It is recommended that everyone upgrade and change all references to $this->controller->Session in the view to the new helper, $session. While not every bug in trac has been fixed, several others were, so check out the change log to see what was done.Download: http://cakeforge.org/frs/?group_id=23&release_id=124 Change Log: http://cakeforge.org/frs/shownotes.php?release_id=124Happy Baking,CakePHP development team-- /** * @author Larry E. Masters * @var string $userName* @param string $realName* @returns string aka PhpNut* @access public*/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
creating and viewing an image database
I am a bit of a beginner to cakePHP, tried RoR but couldn't find decent hosting so thought I'd give PHP a go. I would like to make an image upload and view database, storing the images in the file system isn't really practical for my project. I read the great cakebaker article on uploads (https://cakebaker.wordpress.com/2006/04/15/file-upload-with-cakephp/) and have a much better grasp of that now, but how do I output the blob data stored in the database as an image in a view? Cheers, JP --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Database configuration
This is how I switch configuration class DATABASE_CONFIG { var $default = array('driver' => 'mysql', 'connect' => 'mysql_connect', 'host' => 'mysql50.hub.org', 'login' => '803_swappitto', 'password' => 'swappitto', 'database' => '803_swappitto', 'prefix' => ''); var $dev = array('driver' => 'mysql', 'connect' => 'mysql_connect', 'host' => 'localhost', 'login' => 'swappitto', 'password' => 'swappitto', 'database' => 'swappitto', 'prefix' => ''); var $test = array('driver' => 'mysql', 'connect' => 'mysql_connect', 'host' => 'localhost', 'login' => 'user', 'password' => 'password', 'database' => 'project_name-test', 'prefix' => ''); function DATABASE_CONFIG() { if (0 != DEBUG) { $this->default = $this->dev; } } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Database configuration
milicic.marko wrote: > What is the best way to configure production and development > configuration? > > Should I define $default connection depending on debug level or there > is some smarter solution.. I use this style to switch database configurations : http://withcake.com/posts/view/ease_deployment which works well, you can probably expand upon it to provide more features. In fact it would be good if it was expanded into a more general configuration switching mechanism rather than just the database because as you say you would want a different debug level as well. anyone else ? :) Martin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Database configuration
What is the best way to configure production and development configuration? Should I define $default connection depending on debug level or there is some smarter solution.. Bakers ... help me..please :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Where best to put query logic?
Nope, what you're doing makes complete sense. The purpose of the controller is to act as the "glue" between the model and the view. The controller can also aggregate and operate on other types of data as well, and for some of the logic, you need data outside the model, i.e. session data, so it makes sense that that logic would go in the controller. But if you have any other logic that can be completely contained within the model, by all means, put it there. That's what the object is there for. As always, use common sense. The most important things to remember about the principles that Cake enforces is to maintain separation between the tiers of MVC (most importantly between view and controller), and most importantly, Don't Repeat Yourself. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: Where best to put query logic?
EDIT: Then my controller would be mostly lines like: $this->set('widgets', $this->Widget->getAllWidgets()); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Where best to put query logic?
I'm fairly new to OO development, and I'm probably overthinking this, but ... The manual explains [find($x), findAll($x), findAllBy($x)] as model functions which leads me to want to put all of my dbaccess logic there, within functions like getAllWidgets, getSubWidgets, etc. Then my controller would be mostly lines like: $this->set('widgets', $this->getAllWidgets()); This all makes sense to me, but it seems that all the tutorials and bits of code that I see put most of the logic in the controller, using core model functions directly ... I know I can do it either way, but want to make sure I'm doing it right ... Any thoughts? TIA, Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
advanced validation, complex controller, error helper
I've been experimenting with advanced validation per http://wiki.cakephp.org/tutorials:advanced_validation:advance_validation_with_parameters and the ErrorHelper class. I need my UsersController's update() method to update both the underlying 'users' table as well as the 'people' table that the User model belongsTo. I've discovered that when you just say $this->User->save($this->data['User']) cake updates 'users' table but not 'people'. So I instantiate my own Person object in the UsersController constructor, and assign it to an instance var, which I update it "manually" (it's still pretty easy, thank you Cake) in my update(). But I don't want to update anything unless both models validate. So I check that manually before calling save(). Fine. The only hitch is that in my view update.thtml, I have not been able to figure out to get e.g., $error->showMessage('Person/lastname') to show the validation error that I know to exist from the controller's point of view in $this->Person->validationErrors. I've been trying an ugly workaround as commented in the code below, but I would like to know how to make it work as it does for $error->showMessage('User/username'), and/or what I am doing wrong. Thank you! Here is the controller: Person = new Person(); } function index() { $this->set('users',$this->User->findAll()); } function update($id = null) { if (empty($this->data)) { $this->User->person_id = $id; $this->data = $this->User->read(); } else { // load validation rules $this->User->load_validation(); $this->Person->load_validation(); // if both models validate... $valid_user = $this->User->validates($this->data); $valid_person = $this->Person->validates($this->data); if ($valid_user && $valid_person) { // ...try to save if ($this->User->save($this->data['User']) && $this->Person->save($this->data['Person'])) { $this->flash("User {$this->data['User']['username']} has been updated.",'/users'); } else { debug($this->User->validationErrors); debug($this->Person->validationErrors); } } else { // nasty workaround $this->set('validationErrors',$this->Person->validationErrors); } } } } ?> and here is the view: hidden('Person/id')?> hidden('User/person_id')?> First name input('Person/firstname')?> Last name showMessage('Person/lastname')?>input('Person/lastname')?> Username showMessage('User/username') // <-- but this works fine ?> input('User/username')?> submit('Save')?> Thanks again. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Unable to Access the Models from Admin Controller
Hi, Here is the controller code set('agents', $this->Agent->findAll()); } } ?> and here is the view (agents_index.thtml) Agents Name Company Name City State URL Status View Edit Delete But the page shows the error : Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/houseseeker/app/views/admin/agents_index.thtml on line 15 and it does not show any recrods although there are records in the table agents and also print_r($agents) also outputs nothing. and line 15 is $this->set('agents', $this->Agent->findAll()); Any Ideas. How to make the controller access the records of the Agent Model. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: missing table / forcing $db->listsource() to re-read tables from database
Once again replying to my own post - apprently the only way to achieve this right now is in your code write $db =& ConnectionManager::getDataSource($this->Addon->useDbConfig); $db->__Sources = null; Yes, I am fully aware that __sources is a private variable Thanks to gwoo for the ideas about manipulating DB object with reconnect() etc none of which worked unfortunately Cheers Tarique --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: newbie:othAuth: how to login from a page with a non Admin group?
Thanks CraZyLeGs, you pointed me in the right direction. I have now amended my login action to this... function login() { if(isset($this->params['data'])) { $user_data = $this->params['data']['User']; $username = $user_data['username']; $password = md5($user_data['password']); $userdata[] = $this->User->find("User.username = '$username' AND User.password = '$password'"); $groupid = $userdata['0']['User']['group_id']; $user_data[group_id] = $groupid; $auth_num = $this->othAuth->login($user_data); $this->set('auth_msg', $this->othAuth->getMsg($auth_num)); } } It is all working as it should now, but I was wondering if this was indeed the best way to do it? Should the logic to determine the group membership of the user not be in the component itself? Regards, Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
Re: newbie:othAuth: how to login from a page with a non Admin group?
this is not a bug! yes by default othAuth accepts group_id = 1 you need to have [User][group_id] set in the array you pass to the login method this can come from a selectTag in the form, a hidden field or set manually in the login action before calling othAuth's login method --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---