View Full Version : A problem of specifying two or more methods of a PHP class on a server from a store

28 Dec 2012, 11:51 PM
Hi friends,
Could anyone help me what can I here:

I have one store specifies proxy(type=ajax) and its url (both (server) controller and its method(function))
And through this url I am specifying (PHP) controller method which loads data from database to display in the grid
Now I have a form that should insert(not working) some related data (in grid) into database

I have got my code snippets like this:
This code from the client controller->
addAssignment: function(button){ if(this.getForm().getForm().isValid()){
var win = button.up('window'),
form = win.down('form');
var values = form.getValues();
//here we are in need of the a model instance of the current one
// grid.store.insert(0, values);
this.getUserlogStore().insert(0, values);
This code from the store:
proxy: { type: 'ajax',
url: Server.getUrl('Module.network.userlog','trafficLog'),
reader: {
type: 'json',
root: 'trafficlog',
exception: Server.createReaderExceptionCallback()
//here we have to specify writer for for record writing
writer: {
type: 'json',
//find what root does
// url: Server.getUrl('Module.network.userlog','addUserTrafficLog'),
root: 'logupdate',
listeners: {
exception: Server.createFormFailureCallback()
This code from the server controller->

class UserlogController extends ModuleApp{

public function actionTrafficLog (){

//this command variable stores values using dbCommand of the parent controller by this

$command = $this->dbCommand();//here you ing see that we using moduleApp as a base controller
))->from('user_traffic_log ut')
->where('is_deleted = false');
$this->applySort($command, 'id DESC');
$trafficlog = $command->queryAll();
//this result method of the Controller specifies data send to the client

//from here on we should we would like to craete an action that serves as method for retrieving data from database
//for traffic log info
public function actionAddUserTrafficLog(){

$json = file_get_contents('php://input');

$data = CJSON::decode($json);
//$data = $_POST;
$command = $this->dbCommand();
//keep inmind that calling a insert function of the dbCommand, we should specify table name as a first parameter
// and as a second paramter colums or array values
$result = $command->insert('user_traffic_log', array(

// $logupdate = $command->queryAll();



Thank you in advance

29 Dec 2012, 8:27 AM
Two easy ways:

Easiest with what you have: Use the proxy's api config (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Ajax-cfg-api) to specify the endpoints that should be used for CRUD operations.

Less easy, but more elegant (IMO): Use the Rest proxy (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Rest). It will auto generate endpoints and HTTP verbs based on the particular CRUD action.