Loading ...
Sorry, an error occurred while loading the content.

Can anybady give me the sample PHP code with MVC architecture

Expand Messages
  • santu_hear2u
    Hi, can anyone send me the php sample code with mvc architecture. Thanks in advance, santu
    Message 1 of 4 , Sep 9, 2008
    • 0 Attachment
      Hi,


      can anyone send me the php sample code with mvc architecture.

      Thanks in advance,

      santu
    • Jilani Jidni
      please try 1. CodeIgniter or 2. CakePHP -- with regards Jilani Jidni
      Message 2 of 4 , Sep 9, 2008
      • 0 Attachment

        please try

        1. CodeIgniter or
        2. CakePHP

        --
        with regards

        Jilani Jidni


        On Wed, Sep 10, 2008 at 11:12 AM, santu_hear2u <santu_hear2u@...> wrote:
        Hi,


         can anyone send me the php sample code with mvc architecture.

        Thanks in advance,

        santu


        ------------------------------------

        Visit phpXperts website at www.phpxperts.netYahoo! Groups Links

        <*> To visit your group on the web, go to:
           http://groups.yahoo.com/group/phpexperts/

        <*> Your email settings:
           Individual Email | Traditional

        <*> To change settings online go to:
           http://groups.yahoo.com/group/phpexperts/join
           (Yahoo! ID required)

        <*> To change settings via email:
           mailto:phpexperts-digest@yahoogroups.com
           mailto:phpexperts-fullfeatured@yahoogroups.com

        <*> To unsubscribe from this group, send an email to:
           phpexperts-unsubscribe@yahoogroups.com

        <*> Your use of Yahoo! Groups is subject to:
           http://docs.yahoo.com/info/terms/





      • nurul ferdous
        Dear Santu, you give a try with CakePHP or CodeIgniter to make web applications in MVC design pattern. you will find sample code in MVC pattern here:
        Message 3 of 4 , Sep 10, 2008
        • 0 Attachment
          Dear Santu,
          you give a try with CakePHP or CodeIgniter to make web applications in MVC design pattern. you will find sample code in MVC pattern here: http://www.bakery.cakephp.org/

          ----- Original Message ----
          From: santu_hear2u <santu_hear2u@...>
          To: phpexperts@yahoogroups.com
          Sent: Wednesday, September 10, 2008 11:12:37 AM
          Subject: [phpXperts] Can anybady give me the sample PHP code with MVC architecture

          Hi,

          can anyone send me the php sample code with mvc architecture.

          Thanks in advance,

          santu


        • James
          Its not necessary to use framework to code in MVC style. Of course the controller won t be handling things like it do in such framework but you can follow same
          Message 4 of 4 , Sep 11, 2008
          • 0 Attachment
            Its not necessary to use framework to code in MVC style. Of course the
            controller won't be handling things like it do in such framework but
            you can follow same strategy while coding it yourself and doing it
            manually. I hope i am making sense.

            Have a look at the following sample for your understanding

            Lets say you have this currently
            <?php
            mysql_connect(...);
            $result = mysql_query('select * from news order by article_date desc');
            ?>
            <html>
            <body>
            <h1>News Articles</h1>


            <?php while ($row = mysql_fetch_object($result)) { ?>
            <h2><?php echo $row->headline ?></h2>


            <p>
            <?php echo $row->body ?>
            </p>
            <?php } ?>
            </body>
            </html>

            In order to change to MVC you need to change as following

            Model:

            <?php
            function get_articles()
            {
            mysql_connect(...);
            $result = mysql_query('select * from news order by article_date desc');


            $articles = array();
            while ($row = mysql_fetch_objects($result)) {
            $articles[] = $row;
            }
            return $articles;
            }
            ?>

            Controller:

            <?php
            $articles = get_articles();
            display_template('articles.tpl');
            ?>

            View:

            <html>
            <body>
            <h1>News Articles</h1>


            <?php foreach ($articles as $row) { ?>
            <h2><?php echo $row->headline ?></h2>


            <p>
            <?php echo $row->body ?>
            </p>
            <?php } ?>
            </body>
            </html>

            I hope this is what you have asked? Email me if you need more help or
            any further information on this.

            Cheers


            --- In phpexperts@yahoogroups.com, nurul ferdous <nurul_ferdous@...>
            wrote:
            >
            > Dear Santu,
            > you give a try with CakePHP or CodeIgniter to make web applications
            in MVC design pattern. you will find sample code in MVC pattern here:
            http://www.bakery.cakephp.org/
            >
            >
            >
            > ----- Original Message ----
            > From: santu_hear2u <santu_hear2u@...>
            > To: phpexperts@yahoogroups.com
            > Sent: Wednesday, September 10, 2008 11:12:37 AM
            > Subject: [phpXperts] Can anybady give me the sample PHP code with
            MVC architecture
            >
            >
            > Hi,
            >
            > can anyone send me the php sample code with mvc architecture.
            >
            > Thanks in advance,
            >
            > santu
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.