Pagination issue
Hi all, In the database case_files I have a problem arranging a varchar typecalled case_file_no in ascending order. case_file_no data can be 2,20,21A,21B etc. If i simply just paginate the data and put case_file_no as ascending order, it will go 1,2,20,21,3,4,5 because it is in ascending type, it will look at the first character. So is there any solution for this? that pagination can paginate a varchar correctly? Gangzheng 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: Please Help!! my password is always null!!!
so if i want to use authentication, how should i go about doing it? Gangzheng On Aug 24, 2:03 pm, Martin Westin wrote: > My guess is that Auth component is doing it. > If you are doing your own authentication you have to remove Auth from > your list of components. And if you do want to use Auth ten you > shouldn't do any of the authenticating stuff yourself. > > /Martin > > On Aug 24, 6:50 am, liaogz82 wrote: > > > Hi all, > > > I dont know why but my password is always sent as null in $this->data, > > which causes it to be unable to retrieve data for comparison. The > > following below are my codes: > > > login.ctp > > > > Login > > create('User', array > > ('controller'=>'users','action'=>'login'));?> > > input('User.username');?> > > input('User.password',array > > ('type'=>'password'));?> > > submit('Login');?> > > end(); ?> > > > ?> > > > users_controller.php > > function login() > > { > > $this->layout = 'login'; > > if(!empty($this->data)) > > { > > $user = $this->User->validateLogin($this->data['User']); > > if($user != '') > > { > > $this->Session->write('User', $user); > > $this->Session->setFlash('You\'ve successfully logged > > in.'); > > $this->redirect(array('controller'=>'subscribers', > > 'actions'=>'index')); > > } > > else > > { > > $this->Session->setFlash(json_encode($this->data)); > > $this->redirect(array > > ('controller'=>'users','actions'=>'login')); > > } > > } > > } > > > function logout() > > { > > $this->Session->destroy('user'); > > $this->Session->setFlash('You\'ve successfully logged out.'); > > $this->redirect($this->Auth->logout()); > > } > > > user.php > > class User extends AppModel { > > > var $name = 'User'; > > // var $actsAs = array('Acl' => array('requester')); > > var $useDbConfig = 'tracksdb'; > > > function parentNode() { > > } > > > /* To get the login ID of staff > > function getStaffID() > > { > > return "gangzheng"; > > /* to change. The ID should be gotten from session > > }*/ > > > //The Associations below have been created with all possible keys, > > those that are not needed can be removed > > var $belongsTo = array( > > 'Group' => array('className' => 'Group', > > 'foreignKey' => 'group_id', > > 'conditions' => '', > > 'fields' => '', > > 'order' => '', > > 'counterCache' => ''), > > ); > > > var $hasMany = array( > > 'Login' => array('className' => 'Login', > > 'foreignKey' => 'user_id', > > 'conditions' => '', > > 'fields' => '', > > 'order' => '', > > 'limit' => '', > > 'offset' => '', > > 'dependent' => '', > > 'exclusive' => '', > > 'finderQuery' => '', > > 'counterQuery' => ''), > > ); > > > function validateLogin($data) > > { > > $user = $this->find(array('username' => $data['username'], > > 'password' => sha1($data['password'])), array('id', 'username')); > > if(empty($user) == false) > > return $user['User']; > > return false; > > } > > > } > > > The flash message kept showing {"User": > > {"username":"gangzheng","password":null}}. So i am not sure what is > > going on. the password field is always set to null no matter what i > > type into the password field. Please help. Thanks > > > Gangzheng --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Please Help!! my password is always null!!!
Hi all, I dont know why but my password is always sent as null in $this->data, which causes it to be unable to retrieve data for comparison. The following below are my codes: login.ctp Login create('User', array ('controller'=>'users','action'=>'login'));?> input('User.username');?> input('User.password',array ('type'=>'password'));?> submit('Login');?> end(); ?> users_controller.php function login() { $this->layout = 'login'; if(!empty($this->data)) { $user = $this->User->validateLogin($this->data['User']); if($user != '') { $this->Session->write('User', $user); $this->Session->setFlash('You\'ve successfully logged in.'); $this->redirect(array('controller'=>'subscribers', 'actions'=>'index')); } else { $this->Session->setFlash(json_encode($this->data)); $this->redirect(array ('controller'=>'users','actions'=>'login')); } } } function logout() { $this->Session->destroy('user'); $this->Session->setFlash('You\'ve successfully logged out.'); $this->redirect($this->Auth->logout()); } user.php class User extends AppModel { var $name = 'User'; //var $actsAs = array('Acl' => array('requester')); var $useDbConfig = 'tracksdb'; function parentNode() { } /* To get the login ID of staff function getStaffID() { return "gangzheng"; /* to change. The ID should be gotten from session }*/ //The Associations below have been created with all possible keys, those that are not needed can be removed var $belongsTo = array( 'Group' => array('className' => 'Group', 'foreignKey' => 'group_id', 'conditions' => '', 'fields' => '', 'order' => '', 'counterCache' => ''), ); var $hasMany = array( 'Login' => array('className' => 'Login', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''), ); function validateLogin($data) { $user = $this->find(array('username' => $data['username'], 'password' => sha1($data['password'])), array('id', 'username')); if(empty($user) == false) return $user['User']; return false; } } The flash message kept showing {"User": {"username":"gangzheng","password":null}}. So i am not sure what is going on. the password field is always set to null no matter what i type into the password field. Please help. Thanks Gangzheng --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Finding missing numbers in an array
Hi all, I know this is not directly related to cakePHP but i am cracking my head trying my best to figure out how to discover a missing number in an array in php. Let me give you this example: $missing_array1 = array(1,2,3,4,6,7,8); The missing number for the above array is 5. $missing_array2 = array(1,2,3,4,5,7,8,9); The missing number is 6 Please help me on this. Thanks Gangzheng --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Convert this Mysql Statement to a cakePHP find array
Hi all, I am having some difficulty finding a cakePHP solution to this MySQL statement: SELECT `id`, `issue_date` FROM icapsdb3.print_issues where id >=2043 limit 45,1 Can somebody help me please? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
need help in using observeField
Hi all, I have this project where user key in the no of magazine issue and the id of first issue of the magazine the subscriber received. From these 2 details, the system will check with the database and display the id of the last issue magazine the subscriber will receive in a textfield. All these has to be done without the page refreshing itself, means ajax have to be used. The last issue id calculation is based on 2 parameters: No of issue and first issue id. For example, i have 20 magazine issues no 1 to 20. Subscriber 1 want 5 issues starting from magazine issue 4 so his end issue is magazine issue 8. if he wants 13 issues, his end issue is magazine issue 16 I understand that AjaxHelper::observeField can only observe on one single field. for my case, i need to observe 2 fields, and on top of that i need it to be able to display the ID inside a textfield not . Can this be done? --~--~-~--~~~---~--~~ 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: Extracting numeric data and then add one
Oh yes by the way, the above codes generate this error: Column 'scp_id' cannot be null Means there is no value in $newId2 On Jun 3, 5:32 pm, liaogz82 wrote: > Hi all, > > I need help in cakePHP. > > I am using this framework in my area of work. I have successfully > migrated from the old database that uses an auto increment field as > the primary key to one that uses uuid as the primary key. > unfortunately the users request the old ID to be remain in place so > that they can identify, as UUID is too long and unreadable. > > I am trying my very best to figure out how to do the implementation of > the auto increment in cakePHP, that is to use the codes below: > > $newId = $this->Subscription->find('list', > array( > 'fields'=>'Subscription.scp_id', > 'order'=>'Subscription.scp_id desc', > 'limit'=> 1 > ) > ); > $newId2 = Set::extract($newId,'{0}.Subscription.scp_id'); > $this->data['Subscription']['scp_id'] = $newId2+1; > > the idea is to extract the latest rolling number in scp_id field and > then add 1 to it to become the new identifyable id for the system > users, unfortunately the system keeps giving errors. is there a way > out? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Extracting numeric data and then add one
Hi all, I need help in cakePHP. I am using this framework in my area of work. I have successfully migrated from the old database that uses an auto increment field as the primary key to one that uses uuid as the primary key. unfortunately the users request the old ID to be remain in place so that they can identify, as UUID is too long and unreadable. I am trying my very best to figure out how to do the implementation of the auto increment in cakePHP, that is to use the codes below: $newId = $this->Subscription->find('list', array( 'fields'=>'Subscription.scp_id', 'order'=>'Subscription.scp_id desc', 'limit'=> 1 ) ); $newId2 = Set::extract($newId,'{0}.Subscription.scp_id'); $this->data['Subscription']['scp_id'] = $newId2+1; the idea is to extract the latest rolling number in scp_id field and then add 1 to it to become the new identifyable id for the system users, unfortunately the system keeps giving errors. is there a way out? --~--~-~--~~~---~--~~ 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: Need help on password generation
Hi Bryan, I don't quite understand how to do the echo password thingy. the password is to be displayed in the textbox, something akin to document.getElementById("password"); should i put it under $html- >input? On May 27, 3:28 pm, Bryan Paddock wrote: > Hi Gangzheng, > Use the core ajax helper for that. > > in your controller: > > var $helpers = array('Ajax', 'Javascript') > var $components = array('RequestHandler') > > in the view that is going to hold the link, create the link with the ajax > helper instead of the html helper: > > echo $ajax->link( 'Generate Password', > array( 'controller' => 'controllername', 'action' => > 'generatePassword', > array( 'update' => 'id_of_div_to_be_updated', 'complete' => 'alert("Your > password has been generated") ' ) ); > > then in your generatepassword controller function make sure you send the > generated password to the view which you'll create in your views/controller > folder > > $this->set('password', $new_password); > > so you can print out the password in your view with > > echo $password; > > hope this helps! > > bryan > > On Wed, May 27, 2009 at 8:39 AM, liaogz82 wrote: > > > Hi all, > > > I need help on the cakePHP coding. I have a function called > > generatePassword() in the controller. I want to create an ajax link in > > such a way that user can click on the link and it will talk to the > > method, take the password and display it on the textbox. Can this be > > done? > > > Gangzheng --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Need help on password generation
Hi all, I need help on the cakePHP coding. I have a function called generatePassword() in the controller. I want to create an ajax link in such a way that user can click on the link and it will talk to the method, take the password and display it on the textbox. Can this be done? Gangzheng --~--~-~--~~~---~--~~ 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: Need help converting this MySQL command into cakePHP find()
sorry mistake. I have correct the unknown column problem. But i faced another issue Undefined variable: conditions [APP/controllers/ subscribers_controller.php, line 24] On May 8, 10:09 am, liaogz82 wrote: > Sorry this doesnt work. It still gives me this error: > > Warning (512): SQL Error: 1054: Unknown column 'SubscriberContact' in > 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line > 514] > > is there a way to use joinModel method? > > On May 6, 3:59 pm, Mohsin Kabir wrote: > > > Hello , > > There is easy solution here : > > > here you should > > First: > > make association > > > subscribers has many subscriber_contacts and > > subscriber_contacts belongs to subscribers > > > Second: > > > # find IDs of friends here > > $friends = $this->Subscriber->SubscriberContact->find(’list’, > > array(’conditions’ =>array(‘SubscriberContact.contact_no like ’ => ‘ > > 03-20934662%’))); > > # merge conditions > > $conditions = Set::merge($conditions, array(‘Subscriber.id’ => $friends)); > > > $this->Subscriber->find(’all’, array(‘conditions’ => $conditions)); > > > I think i will help you > > > On Wed, May 6, 2009 at 12:45 PM,liaogz82 wrote: > > > > Hi all, > > > > i need help to convert the following MySQL query to cakePHP find. I > > > have 2 tables: subscribers and subscriber_contacts. One subscriber has > > > many subscriber_contacts. The following is the MySQL query: > > > > SELECT s.* FROM subscribers s, subscriber_contacts sc where s.id = > > > sc.subscriber_id and sc.contact_no like '03-20934662%'; > > > > So question here: how to convert the above MySQL command into a find()? > > > -- > > --~--~-~--~~~---~--~~ > > Thanks, > > Mohsin Kabir > > --~--~-~--~~~---~--~~ --~--~-~--~~~---~--~~ 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: Need help converting this MySQL command into cakePHP find()
Sorry this doesnt work. It still gives me this error: Warning (512): SQL Error: 1054: Unknown column 'SubscriberContact' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 514] is there a way to use joinModel method? On May 6, 3:59 pm, Mohsin Kabir wrote: > Hello , > There is easy solution here : > > here you should > First: > make association > > subscribers has many subscriber_contacts and > subscriber_contacts belongs to subscribers > > Second: > > # find IDs of friends here > $friends = $this->Subscriber->SubscriberContact->find(’list’, > array(’conditions’ =>array(‘SubscriberContact.contact_no like ’ => ‘ > 03-20934662%’))); > # merge conditions > $conditions = Set::merge($conditions, array(‘Subscriber.id’ => $friends)); > > $this->Subscriber->find(’all’, array(‘conditions’ => $conditions)); > > I think i will help you > > On Wed, May 6, 2009 at 12:45 PM, liaogz82 wrote: > > > Hi all, > > > i need help to convert the following MySQL query to cakePHP find. I > > have 2 tables: subscribers and subscriber_contacts. One subscriber has > > many subscriber_contacts. The following is the MySQL query: > > > SELECT s.* FROM subscribers s, subscriber_contacts sc where s.id = > > sc.subscriber_id and sc.contact_no like '03-20934662%'; > > > So question here: how to convert the above MySQL command into a find()? > > -- > --~--~-~--~~~---~--~~ > Thanks, > Mohsin Kabir > --~--~-~--~~~---~--~~ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Need help converting this MySQL command into cakePHP find()
Hi all, i need help to convert the following MySQL query to cakePHP find. I have 2 tables: subscribers and subscriber_contacts. One subscriber has many subscriber_contacts. The following is the MySQL query: SELECT s.* FROM subscribers s, subscriber_contacts sc where s.id = sc.subscriber_id and sc.contact_no like '03-20934662%'; So question here: how to convert the above MySQL command into a find()? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cant use saveAll() to edit $this->data
Hi All, I need help in using saveAll() method for editing, I have a form that needs to save data to 2 different models, Subscriber and Individual subscriber. But everytime i edit data, a new data is being created instead. The following is my codes: subscriber.php (model) class Subscriber extends AppModel { var $name = 'Subscriber'; var $order = 'Subscriber.create_date DESC'; //The Associations below have been created with all possible keys, those that are not needed can be removed var $hasOne = array( 'CompanySubscriber' => array('className' => 'CompanySubscriber', 'foreignKey' => 'subscriber_id', 'conditions' => '', 'fields' => '', 'order' => '', 'dependent' => ''), 'IndividualSubscriber' => array('className' => 'IndividualSubscriber', 'foreignKey' => 'subscriber_id', 'conditions' => '', 'fields' => '', 'order' => '', 'dependent' => ''), ); var $hasMany = array( 'SubscriberContact' => array('className' => 'SubscriberContact', 'foreignKey' => 'subscriber_id', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''), 'Transaction' => array('className' => 'Transaction', 'foreignKey' => 'subscriber_id', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''), ); var $belongsTo = array( 'Country' => array('className' => 'Country', 'foreignKey' => 'country_name', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'dependent' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''), 'State' => array('className' => 'State', 'foreignKey' => 'state_name', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '',
weird baking situation
Hi all, while i was baking cakePHP with a mysql database, I have this situation where I was requested to confirm an association "Payment belongsTo Pay? (y/n)". I find this weird cos I do not have a database called Pay. Is pay some kind of an attribute in cakePHP that i should associate with it? Is it because there is a pay class in Cake PHP that cause this? Please enlighten me as i am new to this. --~--~-~--~~~---~--~~ 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: Using PHP to export MySQL data MS excel files
hi Reggie, As i am a newbie in cakePHP, I am not sure how to integrate the pear libraries into the vendor folder of cake. Have you publish any documents or post any blog that will aid me in getting started? On Dec 10, 3:12 am, Reggie Mason <[EMAIL PROTECTED]> wrote: > I've had success with the PEAR's Spreadsheet Excel Writer > --http://pear.php.net/package/Spreadsheet_Excel_Writer, with CakePHP. > I'm not sure about charts; I'd leave that to Excel. Make sure PEAR is > in your include path, and include it in your view. Enjoy. > > On Nov 26, 12:54 am, liaogz82 <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am looking into ways to use cakePHP to query into MySQL database to > > extract out the relevant data, then export out a report in MS excel > > that will include several pie charts. Such reports are to review by > > user on the browser first before it is being exported. Is there anyway > > to do it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Using PHP to export MySQL data MS excel files
Ok i thought of another alternative What about I have an excel template that is pre-made, and i just want cakePHP to write values to the selected cells. Once the selected cells is being populated, the excel will use the numbers to draw up the relevant chart? On Nov 28, 3:45 am, James K <[EMAIL PROTECTED]> wrote: > Yes, it's definitely possible. But it's also definitely not easy. > > Excel 2007's .xlsx format is simply a zip file containing a whole > bunch of XML files. You could write code that produce those xml files, > zips it up, call it xlsx and delivers it to the user. > > A shortcut I commonly use is to produce an HTML table, and send that > to the client as an xls file (The RequestHandler in Cake makes it easy > to spoof your resultant view as a downloadable file). Excel is smart > enough to recognize an HTML table as tabular data and display it as > such. Excel 2007 will complain, but it will still handle it correctly. > > You won't get any pie charts that way, though. > > Anything else is going to likely cost you. Business intelligence and > reporting tools that can generate the kind of reports you're looking > for are generally very expensive (several thousand dollars), and are > difficult to integrate into an application. > > Good luck, > James > > On Nov 26, 1:54 am,liaogz82<[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am looking into ways to use cakePHP to query into MySQL database to > > extract out the relevant data, then export out a report in MS excel > > that will include several pie charts. Such reports are to review by > > user on the browser first before it is being exported. Is there anyway > > to do it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Using PHP to export MySQL data MS excel files
Hi, I am looking into ways to use cakePHP to query into MySQL database to extract out the relevant data, then export out a report in MS excel that will include several pie charts. Such reports are to review by user on the browser first before it is being exported. Is there anyway to do it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---