How to Get Last Update id in Cake PHP - cakephp-2.0

I want to update set of Records, so iam using following code and then i need update the updated row id to another table, so i want to Last Updated Row ID
$this->mymodel->updateAll(array('field1'=>0),array('field5'=>0));

In order to get the ID of the last row, you can simply use this getID function:
$this->(Model Name)->getID()
Check out the following reference for more relevant functions: http://book.cakephp.org/2.0/en/models/additional-methods-and-properties.html
Peace! xD :)

Related

Query of Arrays in Salesforce

I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!

How to print all values with same key in one row?

I am new in AngularJS. I wanted to ask how to print all the values with similar key in a row, then another set of values with similar key in another row. For eg. I have to print employees name with similar age in one row etc..Can anybody give me a solution?
It's better to have data as array for ng-repeat.
Now, pre process that data in controller or service to group them based on the criteria ( same age in your case ) and then simply ng-repeat.

Get value from select record in store

Hello I'm have store and I want get value in field ID from this store.
Ext.ComponentQuery.query('price gridpicker[name=price]')[0].store.getAt(0).data.id;
But this output only ID from first record in store, and when select other record I will still get ID from first record, help me thanks
If you want to get the selected record then you need to query the grid, not the store. The store just contains the data, it doesn't know what's going on on the screen.
Ext.ComponentQuery.query('price gridpicker[name=price]')[0].getGrid().getSelectionModel().getSelection()[0].get('id');
The correct call is:
...getAt(0).get('id);
or, if you want all record's data then
...getAt(0).getData();
Of course, you can get also other values but you need to know which record is selected by the gridpicker.

last generate id manual query in cakephp

I have apply manual query in cakephp and not get last generate id
My query is this
$areas = $this->Area->query("insert into areas (Area_ID,Parent_Area_ID,Area) values ('','".$Parent_Area_ID."','".$Area_name."')");
How i get last id ?
Try this code:
$this->Area->getInsertID();
More detail here:
http://book.cakephp.org/2.0/en/models/additional-methods-and-properties.html#model-getinsertid
Try this
echo $this->Area->getLastInsertID();
If this doesn't work check out this answer from a similar question

Can we Change the default fieldname parent_id to FldParentId in Cake Php for Find('thread') statement?

I have changed the fieldname parent_id to FldParentId in a Table admin_menus. I want to select all the sub menus under a particular parent_id. but it gives an notice like
"Notice (8): Undefined index: parent_id [CORE/cake/libs/model/model.php, line 2337]".
So my question is that can I change this fieldname from parent_id to FldParentId.Is that possible..or I have to keep this fieldname as parent_id??
Please help me out..I need to know dat..
Thanks in advance.
Since there is no option to overwrite the key to use for the find('threaded') method you need to keep the fieldname like the way CakePHP wants it or you could overwrite the method used by CakePHP in your AppModel.
Seecake/libs/model/model.php on line 2311 where you can find the _findThreaded function to see how this is working.
I would just rename the field if you have no other dependencies on it.

Resources