Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    1
    Vote Rating
    0
    thisisatin is on a distinguished road

      0  

    Default read and write from/to mysql database

    read and write from/to mysql database


    Hi,

    i am new to Sencha. im developing an app where it connects to Mysql db and pulls some customers from customer table (eg. cust_code, cust_name) and populates a list on load.

    it then stores this list offline and user can add a new customer or edit an existing one and this later gets synced to mysql db.

    do i need to know php for this? what options do i have? please give me some examples..

    please help.

    thanks,
    atin..

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi thisisatin,

    Yes you need know about php or any server side language.See the sample example for load/update record from Mysql -

    view.js
    Code:
     Ext.onReady(function() {
        var cols = [
        { dataIndex: 'id', header: 'id', hidden: true },
        { dataIndex: 'title', header: 'Title', width: 200, editor: 'textfield'},
        { dataIndex: 'author', header: 'Author', width: 200, editor: 'textfield' },
        { dataIndex: 'isbn', header: 'ISBN', width: 100, editor: 'numberfield' },
    ],
    
        fields = [];
            for(var i=0; i<cols.length; i++) {
            fields.push(cols[i].dataIndex);
        }
    
    Ext.define('Book', {
        extend: 'Ext.data.Model',
        fields: fields 
    });
    
    var store = Ext.create('Ext.data.JsonStore', {
        model: 'Book',
        proxy: {
            type: 'ajax',
            url: 'view.php',
            reader: {
                type: 'json'
            }
        }
    });
    
    Ext.create('Ext.grid.Panel', {
        columns: cols,
        width: 520,
        style: 'margin-top: 20%; margin-left: 35%',
        renderTo: Ext.getBody(),
        store: store
    });
    store.load();
    });


    php code-
    (fill above grid form table record)

    view.php
    Code:
    
    <?php
    
    require_once 'db.php';
    
    $result = mysql_query('SELECT * FROM books');
    while ($row = mysql_fetch_assoc($result)) {
    
        for ($i=0; $i < mysql_num_fields($result); $i++) {
            $meta = mysql_fetch_field($result, $i);
            }
        $rows[] = $row;
    }
    
    print (json_encode($rows));
    ?>
    


    Simple Extjs form for add record into mysql table
    edit.js-
    Code:
    Ext.onReady(function(){
    Ext.QuickTips.init();
    var simpleForm = new Ext.FormPanel ({
        labelWidth: 75,     
        url:'edit.php',    
        frame:true,
        title: 'Add book',
        bodyStyle:'padding:5px 5px 0',
        width: 350,
        defaults: {width: 230},
        defaultType: 'textfield',
    
            items: [{
                fieldLabel: 'Title',
                name: 'title',
                allowBlank:false
                },{
                fieldLabel: 'Author',
                name: 'author'
                },{
                fieldLabel: 'ISBN',
                name: 'isbn'
            }],            
            buttons: [{
                text: 'Save',          
                handler: function () {
                    simpleForm.getForm().submit({
                        waitMsg: 'Saving...',   
                        success: function () {     
                            Ext.MessageBox.alert ('Message','Data has been saved');
                            simpleForm.getForm().reset();
                        },
                      failure: function () {   
                            Ext.MessageBox.alert ('Message','Saving data failed');
                        }
                    });
                }
            },{
                text: 'Cancel',
                handler: function () {
                    simpleForm.getForm().reset();
                }
            }]
        });
        simpleForm.render ('simple-form');
    });


    edit.php (for save record into table)
    Code:
    <?php
        require_once 'db.php';
        $q=mysql_query ("INSERT INTO books (title, author, isbn) VALUES (null, '".$_POST['title']."','".$_POST['author']."','".$_POST['isbn']."')
        ") or die ('{"success":"false"}');
    
        // json output to notify the insert is success or not
        if ($q) {
            echo '{"success":"true"}';
        }
        else {
            echo '{"success":"false"}';
        }
    ?>

    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    7
    Vote Rating
    0
    a6985600 is on a distinguished road

      0  

    Default test

    test


    test

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Location
    Hong Kong
    Posts
    6
    Vote Rating
    0
    fc338339 is on a distinguished road

      0  

    Default


    Great info, which I have search for a year long.
    1. Would you mind also post the content of "db.php"
    2. Would you mind to provide examples file in Sencha Architect 2

    Thanks for your works

    Fion

  5. #5
    Sencha User
    Join Date
    Jan 2013
    Posts
    1
    Vote Rating
    0
    Girish07 is on a distinguished road

      0  

    Default


    i am new in sencha touch how to data store in mysql database please help me
    thanks in advance