cakephp-2.1

CakePHP 2.1.1 foreach

有些话、适合烂在心里 提交于 2020-01-06 07:31:10
问题 In my view I want a HTML table something like this: COUNTRY TOWN france paris This is my query: $foo=$this->country->find('all', array( 'contain' => array( 'Town' => array( 'conditions' => array("Town.country_id = country.id"), 'fields' => array('id','name') ) ) ) ); I want to display to my view like this: line6 <?php foreach ($diponibilite as $f): ?> line7 line8 <tr> line9 <td><?php echo $f['country']['name'];?></td> line10 <td><?php echo $f['town']['name'];?></td> line11 line12 </tr> line13

MySql query in cake php Api

天大地大妈咪最大 提交于 2020-01-06 06:53:07
问题 for data retrieval i need to use binary keyword for case sensitive search in mysql this is the query i want to make SELECT username FROM users WHERE BINARY first_name LIKE 'eph%' OR BINARY last_name LIKE 'eph%' OR BINARY username LIKE 'eph%' and this is the query i have made in cakephp without binary $this->User->find('list', array( 'fields' => array('User.username'), 'conditions' => array("OR" => array("BINARY User.last_name LIKE" => $search_data."%","BINARY User.username LIKE" => $search

Add a new translatable field to an existing translatable table in CakePHP 2.2

此生再无相见时 提交于 2020-01-02 23:35:33
问题 I'm using CakePHP's translatable behavior. I have a few existing fields working fine, but I'm having trouble adding a new translatable field to my model. CakePHP uses an INNER JOIN to fetch all translatable fields from the database. Now, if I add an extra translatable field to my model, all the translation records for that field won't exist in the database. And because of the inner join, whenever it tries to fetch ANY existing records from the database, it will return blank - because the

Dynamically add virtual field in cakephp

半世苍凉 提交于 2020-01-01 22:06:42
问题 I am using CakePHP 2.1.3; I want to create a virtual field dynamically in a controller. Is it possible? The problem is when I am trying to find max value in a table it gives me another array from the model array. Please ask if you need more information. When I am trying to execute the following query, $find_max_case_count = $this->CaseMaster->find('first', array( 'conditions' => array( 'CaseMaster.CLIENT_ID' => $client_id, 'CaseMaster.CASE_NO LIKE' => '%-%' ), 'fields' => array('max

Dynamically add virtual field in cakephp

北城以北 提交于 2020-01-01 22:06:11
问题 I am using CakePHP 2.1.3; I want to create a virtual field dynamically in a controller. Is it possible? The problem is when I am trying to find max value in a table it gives me another array from the model array. Please ask if you need more information. When I am trying to execute the following query, $find_max_case_count = $this->CaseMaster->find('first', array( 'conditions' => array( 'CaseMaster.CLIENT_ID' => $client_id, 'CaseMaster.CASE_NO LIKE' => '%-%' ), 'fields' => array('max

Error PDO Exception SQLSTATE[42000] when using CakeDC Users plugin

纵然是瞬间 提交于 2019-12-25 03:43:20
问题 Iam using cakephp 2.2.1 and trying to use the cakedc users plugin, when I try to create a user I get the following error, can anyone give some tips or advice to resolve this error - I have loaded all tables using the migrations plugin. Thanks in advance :). 2013-04-07 06:31:33 Error: [PDOException] 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

How i can display validation error message in webservice

强颜欢笑 提交于 2019-12-25 02:26:22
问题 I get validation error message in $this->User->validationErrors; But problem is when i assign like DebugBreak(); //For debug my script $response['type']='error'; $error = $this->User->validationErrors; $response['message'] contains empty array. why this happen? help me. 回答1: When I remove DebugBreak from my script then it work perfect like this $response['type']='error'; $error = $this->User->validationErrors; 来源: https://stackoverflow.com/questions/22929323/how-i-can-display-validation-error

How to implement distance queries in CakePHP?

做~自己de王妃 提交于 2019-12-25 01:36:01
问题 I have a query (from Google Maps) like so: SELECT ( 3959 * acos( cos( radians(MY_LAT) ) * cos( radians( LATITUDE ) ) * cos( radians( LONGITUDE ) - radians(MY_LONG) ) + sin( radians(MY_LAT) ) * sin( radians( LATITUDE ) ) ) ) AS distance FROM zips ORDER BY distance I would rather this be a custom find in Cakephp, so how do I do that? MY_LAT and MY_LONG are params passed in. LATITUDE and LONGITUDE are columns in zips table. 回答1: You can use a behavior like the geocoder behavior ( https://github

The connection was reset issue in CakePHP 2.2

只谈情不闲聊 提交于 2019-12-24 18:18:45
问题 I am new to cakephp when i am trying to make dynamic drop down list of cities on the basis of states then i am getting this error The connection was reset. My js code is $(document).ready(function(){ $('#UserState').change(function(){ var stateid=$(this).val(); $.ajax({ type: "POST", url: "checkcity", data:'stateid='+stateid+'&part=checkcity', success: function(data) { $("#city_div").html(data); } }); }); }); And for this i am using function checkcity on User controller. here is my user

Routing in CakePHP to vanity urls

一个人想着一个人 提交于 2019-12-24 07:37:38
问题 I was wondering if there was an easy and best practices way to make routes in CakePHP (routes.php file) to map userIDs to a vanity url? I have (terrible way to do this) the following test code in my routes page: $users = array ( 1 => 'firstname-lastname', 2 => 'firstname2-lastname2' ); //profiles foreach($users as $k => $v) { // LESSONS (Profiles) Router::connect('/:user', array('controller' => 'teachers', 'action' => 'contentProfile', $k), array('user' => '(?i:'.$v.')')); } The above code