cakephp-2.1

CakePHP re-populate list box

与世无争的帅哥 提交于 2019-12-20 07:09:27
问题 I have a question about cakePHP. I create two drop down lists in my view. When the user changes the value in one list, I want the second to change. Currently, I have this working like this: An on click event fires when the user selects from list box one. This fires a jQuery ajax function that calls a function from my controller. This is all working fine, but how do I re-render my control, asynchronously (or, view)? I i know I could just serialize the array to json and then recreate the

Auth login with email or mobile Cakephp

最后都变了- 提交于 2019-12-20 06:16:20
问题 I am working on cakephp 2.x.i have a table in my database name user and it has 4 fields id, email, password and mobileNo i have two fields in my login.ctp <?php echo $this->form->create(); echo $this->form->input('email'); echo $this->form->input('password'); echo $this->form->end('submit'); ?> what i want is i want to login the user from his mobileNo too(if he typed mobile number rather then email address) just like facebook has done ..he can either login with hi email address or mobileno .i

Global variable in controller cakephp 2

人走茶凉 提交于 2019-12-19 09:59:19
问题 What's the way to have a global variable inside a controller? I have tried to do it using beforeFilter but it is not accessible from the others functions. Can it only be done using Configure::read and Configure::write 回答1: you can set variable accessible in any controller in your AppController class AppController extends Controller { public $myGlobalVar; public function beforeFilter() { //this can be anything array, object, string, etc ..... $this->myGlobalVar = "test2"; } } then in your

Global variable in controller cakephp 2

让人想犯罪 __ 提交于 2019-12-19 09:58:13
问题 What's the way to have a global variable inside a controller? I have tried to do it using beforeFilter but it is not accessible from the others functions. Can it only be done using Configure::read and Configure::write 回答1: you can set variable accessible in any controller in your AppController class AppController extends Controller { public $myGlobalVar; public function beforeFilter() { //this can be anything array, object, string, etc ..... $this->myGlobalVar = "test2"; } } then in your

CakePHP custom validation with a variable in the error message

余生长醉 提交于 2019-12-19 07:12:07
问题 Good afternoon. I have a Model that has a field called "percentage". All similar Models cannot have their percentages add up to more than 100%. Checking for this is handled during validation. I need the validation error message to say how much percentage "room" the user has left. For example, if all MyModels already have a total of 80% and the user tries to create a new MyModel with a percentage of 40%, the error message would say, "Your percentage is too high. You only have 20% remaining."

CakePHP custom validation with a variable in the error message

邮差的信 提交于 2019-12-19 07:11:41
问题 Good afternoon. I have a Model that has a field called "percentage". All similar Models cannot have their percentages add up to more than 100%. Checking for this is handled during validation. I need the validation error message to say how much percentage "room" the user has left. For example, if all MyModels already have a total of 80% and the user tries to create a new MyModel with a percentage of 40%, the error message would say, "Your percentage is too high. You only have 20% remaining."

Strict standards: Redefining already defined constructor for class Object in path\cake\libs\object.php on line 54

a 夏天 提交于 2019-12-18 16:12:33
问题 I am trying to configure MS-MSQL database on cakephp (Not mysql). My Wampserver is 2.2e-php5.4.3-httpd2.2.22-mysql5.5.24-32b on my laptop (which is windows x64-bit. I already invited these two dlls to run sql server extension=php_sqlsrv_54_ts.dll extension=php_pdo_sqlsrv_54_ts.dll I've got these two errors in running cakephp 1.3 Strict standards: Redefining already defined constructor for class Object in C:\wamp\www\project\cake\libs\object.php on line 54<br/> Strict standards: Non-static

how to add active class in current page in CakePhp

北战南征 提交于 2019-12-18 13:31:22
问题 i have a problem similar to this question How to identify active menu link in CakePHP i have a page in my default.ctp file in which i want to add 'active' class on links. how can i identify the current url of the page and then apply the class on link.. i have followed the answer also there which is $url = $this->Html->url('INPUT_THE_URL') ; $active = $this->request->here == $url? true: false; i dont know how can i do this in my code .. sorry for asking as i am newbie in cakephp .. here is my

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual

被刻印的时光 ゝ 提交于 2019-12-17 20:42:43
问题 Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@g.com, 'User'.'phone' = 87665r5, 'User'.'address' = 23lsdhf, 'User'.'location' ' at line 1 SQL Query: UPDATE 'cake'.'users' AS 'User' SET 'User'.'username' = paul, 'User'.'password' = eben, 'User'.'email' = paul@g.com, 'User'.'phone' = 87665r5, 'User'.'address' = 23lsdhf, 'User'.'location' =

cakephp friendship between users Linking models together

自闭症网瘾萝莉.ら 提交于 2019-12-14 03:34:13
问题 What I need: A facebook-like friendship system. User (A) sends a requests for a friendship with User (B) User (B) confirmes the request User (A) and User (B) are friends now My problem: I'm confused how to work this out. I read a lot on the internet but it did not really helped me... My Questions: What kind of link is it in CakePHP? Is it hasAndBelongsToMany? Or hasMany? Or ...? How do I realise it in the datebase correctly? How do I link it in the model? What I already did: Table: users Name