Re: Foreach saveField fails
did you change id to CHAR(36) in mysql ? you could alter table by adding a temporary 'newid' field $this->saveField('newid', $new); once looks good remove id, rename newid to id, add indexes etc... or UPDATE entries SET id = uuid(); Careful if you have related tables with foreign key, as those need to be updated as well.. Andras Kende http://www.kende.com On May 30, 2013, at 11:38 AM, Advantage+ wrote: > I am switching up a table 'id' field and simple doing a find all, generate a > UUID, and try to update the field foreach but all its doing is creating new > empty records. > > > foreach($this->find('all') as $entry) { > $new = String::uuid(); > $this->id = $entry['Entry']['id']; > //debug($this->id); > $this->saveField('id', $new); > } > > If I remove the commented out debug() I get all the original id's but it > simply not update the record. > > Even tried $this->updateAll(array('Entry.id' => $new), array('Entry.id' => > $entry['Entry']['id'])); > > But that does not seem to work eiter. > > Any ideas? > > > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to cake-php+unsubscr...@googlegroups.com. > To post to this group, send email to cake-php@googlegroups.com. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Foreach saveField fails
I am switching up a table 'id' field and simple doing a find all, generate a UUID, and try to update the field foreach but all its doing is creating new empty records. foreach($this->find('all') as $entry) { $new = String::uuid(); $this->id = $entry['Entry']['id']; //debug($this->id); $this->saveField('id', $new); } If I remove the commented out debug() I get all the original id's but it simply not update the record. Even tried $this->updateAll(array('Entry.id' => $new), array('Entry.id' => $entry['Entry']['id'])); But that does not seem to work eiter. Any ideas? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: User defined id
Set the 'type' of the input to 'text; echo $this->Form->input('id', array('type' => 'text')); Jeremy Burns Class Outfit http://www.classoutfit.com On 30 May 2013, at 14:04, Eros Zanchetta wrote: > Hi there, > > I'm just starting a new project with Cakephp but I'm stuck with a very basic > problem. > > I have a "countries" table that looks like this: > > CREATE TABLE `countries` ( > `id` varchar(7) NOT NULL DEFAULT '', > `name` varchar(255) NOT NULL DEFAULT '', > `description` varchar(255) NOT NULL DEFAULT '', > PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > As you can see want to use a VARCHAR as primary key as I want to use a > customized country code as primary key (e.g. FR-2013, DE-2010, ES-2010 etc), > I also want users to be able to manually insert this code. I know using a > non-numeric id is not recommended but I have my reasons. > > Now, when I create a form to add data (I want users to be able to add new > countries), the `id` field is automatically hidden, I could probably come up > with a workaround but I was wondering if there a "proper" way to do it. > > I also have other tables where I have a similar situation. > > Thanks, > Eros > > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to cake-php+unsubscr...@googlegroups.com. > To post to this group, send email to cake-php@googlegroups.com. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Is there a way to get a 'has many' relationship left joined without forcing the join such that I can get a count of the child table?
I am trying to extend the blog example where my Posts belong to Users and Posts has many comments and to get a query where the comments are left joined into the query such that I can get a comment count for each post for listing out in my index page. According to the documentation, it should be able to work, but after trying nearly everything I could find in the documentation including changing recursive to 1 and using contain, the paginate call to find_all still refuses to include comments in the join list such that I get an error that the comments.id was not found. When I get rid of the count, fields, and contain and set recursive to 1, it generates 2 separate queries, the first left joining the posts with the users, the second querying the comments. Is there something I am missing? This is the Query I am expecting: SELECT `Post`.`id`, `Post`.`user_id`, `Post`.`title`, `Post`.`post`, `User`.`id`, `User`.`role`, `User`.`username`, `User`.`password`, `User`.`email`, `User`.`Avatar`, `User`.`first_name`, `User`.`last_name`, `User`.`created`, COUNT(`Comment`.`id`) comments FROM `blog`.`Posts` AS `Post` LEFT JOIN `blog`.`Comments` AS `Comment` ON (`Comment`.`Post_id` = `Post`.`id`) LEFT JOIN `blog`.`users` AS `User` ON (`Post`.`user_id` = `User`.`id`) WHERE 1 = 1 GROUP BY `Comment`.`post_id`; This is what is produced: SELECT `Post`.`id`, `Post`.`user_id`, `Post`.`title`, `Post`.`post`, `User`.`id`, `User`.`role`, `User`.`username`, `User`.`password`, `User`.`email`, `User`.`Avatar`, `User`.`first_name`, `User`.`last_name`, `User`.`created`, COUNT(`Comment`.`id`) comments FROM `blog`.`Posts` AS `Post` LEFT JOIN `blog`.`users` AS `User` ON (`Post`.`user_id` = `User`.`id`) WHERE 1 = 1 GROUP BY `Comment`.`post_id`; using this code: $this->Question->recursive = 1; $this->set('userId',$this->Auth->user('id')); $this->Question->Behaviors->load('Containable', array('autoFields' => false)); $this->paginate =array( 'fields' => array('Question.id', 'Question.user_id', 'Question.title', 'Question.question', 'User.id', 'User.role', 'User.username', 'User.password', 'User.email', 'User.Avatar', 'User.first_name', 'User.last_name', 'User.created', 'COUNT(Comment.id) answers' ), 'group' => 'Comment.question_id', 'contain' => array('User','Comment.id')); $this->set('questions', $this->paginate()); Is the only way to get it to work without using my own SQL to specify all the fields and force the joins? Adding Joins to the options, I can force the join and it works like I want, but shouldn't it be able to figure out the joins by itself with the contain specifying the comment table? Code for options with forced Join for the comments table: $this->paginate =array( 'fields' => array('Question.id', 'Question.user_id', 'Question.title', 'Question.question', 'User.id', 'User.role', 'User.username', 'User.password', 'User.email', 'User.Avatar', 'User.first_name', 'User.last_name', 'User.created', 'COUNT(Comment.id) answers' ), 'group' => 'Comment.question_id', 'joins' => array(array( 'table'=>'Comments', 'alias'=>'Comment', 'type'=>'LEFT', 'conditions'=>array('Comment.question_id = Question.id'))) , 'contain' => array('User','Comment.id')); -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: autoComplete with jquery in cake 1.3
i got same problem, pls help thanks Pada Selasa, 29 Januari 2013 17:31:02 UTC+7, Chris menulis: > > hi guys,.. can you help me please,... > I'm in cake 1.3 and using jquery libraries > > I got all setup, including jquery.autocomplete.min.js from Ajax Javascript > helper http://www.cakephp.4uk.pl/ajax/autoComplete ,... > I can see the "fistnames" in autocomplete form field, but I can't select > them,... > > how can I fix this...? > > this is my form: > > Form->create('User'); ?> > > > autoComplete('User.firstname', '/users/autoComplete', > array('label' => false)); ?> > > > > Form->end(__('Search', true)); ?> > > > > this is my function: > > function autoComplete() { > > $this->set('members', $this->User->find('all', array( > 'conditions' => array( > 'User.firstname LIKE' => $this->params['url']['q'].'%' > ), > 'fields' => array('firstname') > ))); > $this->layout = 'ajax'; > } > > and this is auto_complete.ctp file: > > > > > > > > > > thanks in advance > chris > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Missing Controller Error
josexato: * * *Thanks a lot. Looks like this error can be caused by n number of things. Your suggestion worked in my case. I forgot to put the php tag at the start and the end. It is missing in the cakephp doc and may be miss leading lot of beginners. * On Sunday, December 30, 2012 6:28:17 PM UTC-8, josexato wrote: > > you need to add " > # cat PostsController.php > * class PostsController extends AppController { > > public function index() { > $this->set('posts', $this->Post->find('all')); > } > } > ?> > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
File load from server javascript cakephp2
** I have a aplication in cakephp2. In home.ctp I wan't to use a javascript function to load a file from filesystem and create a track in a map, but I donnĀ“t know how to locate it. In the javascript function I declare a var with the name of the file and then I check if the file exists, and always return false. var gpxfile='WWW_ROOT.files.DS.hoyo.gpx'; if(file_exists(gpxfile)){ alert('Si existe');} else { alert('No existe'); } I tried with the names: var gpxfile='WWW_ROOT.files.DS.hoyo.gpx'; var gpxfile='/app/files/hoyo.gpx'; var gpxfile='/files/hoyo.gpx'; var gpxfile='/webroot/files/hoyo.gpx'; But nothing. How can I locate it? It is necesary to configure the core.php? Thanks -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
connect to remote server (my sql apache)
hi all, Does any one have any idea how to connect to remote server in cakephp??? i have one local database which does have most of required information for application to run but some data is needed from remote server. it means i want to connect cakephp to 2 databases at a time one local and one remote is it possible? can any one help ? thanks. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
How to insert looping checked box value into db?
This is my code and attached the format i need please check it. *INDEX.CTP* * * Form->Create('Schedule'); $appday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); $apptime = array('01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00'); ?> '.$apptime[$k].''; } echo ''; ?> '.$appday[$i].''; for($j=0; $j<23; $j++) { ?> Form->checkbox($appday[$i].'.'.$apptime[$j],array('hiddenfield' =>false)); ?> '; } ?> Form->end('Submit'); ?> -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out. <>
User defined id
Hi there, I'm just starting a new project with Cakephp but I'm stuck with a very basic problem. I have a "countries" table that looks like this: CREATE TABLE `countries` ( `id` varchar(7) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '', `description` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; As you can see want to use a VARCHAR as primary key as I want to use a customized country code as primary key (e.g. FR-2013, DE-2010, ES-2010 etc), I also want users to be able to manually insert this code. I know using a non-numeric id is not recommended but I have my reasons. Now, when I create a form to add data (I want users to be able to add new countries), the `id` field is automatically hidden, I could probably come up with a workaround but I was wondering if there a "proper" way to do it. I also have other tables where I have a similar situation. Thanks, Eros -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Ajax Pagination Example
Hi Guys, I am a new to CakePHP. I got the basic example running in my local environment. I need to implement Ajax based pagination of search results returned from a database query. I have been unsuccessfully searching the internet for a simple ajax pagination CakePHP example. I have lost lot of time so far. Since this is a very common requirement for all the websites I thought I will find lot of examples but to my surprise i did not. Can you please point me to any example that works with the current CakePHP version? Thanks a bunch, Muneer -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: php cms and rewriteRule and cakephp routes
We use our own CMS with CakePHP websites (we're currently translating our own cms into a new cakephp cms.). We use the same structure as you, (app, lib, plugins, vendors, cms) and we don't do anything with the .htaccess files inside the cakephp part (we also use routes, but don't create a /cms route especially). We do have this inside our cms map in the .htaccess: RewriteEngine On RewriteBase / RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/$ cms/?module=$1&page=$2&pagenumber=$3&get4=$4&get5=$5 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ cms/?module=$1&page=$2&pagenumber=$3&get4=$4 [L] RewriteRule ^(.*)/(.*)/(.*)/$ cms/?module=$1&page=$2&pagenumber=$3 [L] RewriteRule ^(.*)/(.*)/$ cms/?module=$1&page=$2 [L] RewriteRule ^(.*)/$ cms/?module=$1 [L] We can access our cms at websitename.com/cms. I hope something like this will also work for you! -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Routes and multilanguage site
That worked! Thanks! I feel so stupid now haha. We tried so many things and in the maintime it would all have worked if we had just put that part below everything else. Op donderdag 30 mei 2013 08:28:02 UTC+2 schreef Bogdan Soos het volgende: > > Hi there, > > Try changing the order, nothing is being routed after your first rule, at > least move the first rule at the end, that should be your last rule. > > Regards, > Bogdan. > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.