久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何將獨(dú)立的 PHP 文件轉(zhuǎn)換為 Magento 的 MVC

How to convert standalone PHP files to Magento#39;s MVC(如何將獨(dú)立的 PHP 文件轉(zhuǎn)換為 Magento 的 MVC)
本文介紹了如何將獨(dú)立的 PHP 文件轉(zhuǎn)換為 Magento 的 MVC的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一項(xiàng)任務(wù)是將獨(dú)立的 PHP 文件轉(zhuǎn)換為 Magento 的 MVC.這些 PHP 文件是由另一位開發(fā)人員創(chuàng)建的.PHP 文件中的代碼訪問數(shù)據(jù)庫,將結(jié)果轉(zhuǎn)換為 JSONP 格式并轉(zhuǎn)發(fā)給前端開發(fā)人員.

I have a task to convert the standalone PHP files to Magento's MVC. These PHP files were created by another developer. The code in the PHP file accesses the database, converts the result into JSONP format and forward it to the frontend developer.

我對 Magento 的 MVC 一無所知.這個(gè)轉(zhuǎn)換任務(wù)和Magento文件夾中app/code/core/Mage中的模塊類似嗎??我怎樣才能做到這一點(diǎn)?magento MVC 和 PHP MVC 一樣嗎?

I don't have any knowledge of Magento's MVC. Is this task of conversion similar to the modules in the app/code/core/Mage in the Magento folder?? How can I do this? Is the magento MVC the same as the PHP MVC?

我包含了需要轉(zhuǎn)換為 Magento MVC 的 php 文件.這樣你會更容易理解..

I am including the php file that I need to convert to Magento MVC. So it will be easier for you to understand..

<?php header('content-type: application/json; charset=utf-8');
$link = mysqli_connect("localhost", "db_username", "password", "db_dbname");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s
", mysqli_connect_error());
    exit();
}

$pid = $_REQUEST['prodid'];

/* Select queries return a resultset */

$result = mysqli_query($link, "SELECT round(rating_summary / 20) AS search_rating FROM review_entity_summary where store_id = 1 and entity_pk_value=" . $pid);

// printf("Select returned %d rows.
" . "<br>
", mysqli_num_rows($result)) . "<br>
";
//$string = $_REQUEST['varname'];
    $rows = array();
  /*  while ($row = $result->fetch_row()) {
                printf("%s
", $row[0]);
            }*/
//while($r = mysql_fetch_assoc($result)) {
while ($r = mysqli_fetch_assoc($result)) {
    $rows = $r;
//print_r ($rows) . "<br>
";
}
$json_data = json_encode($rows);
print_r ($json_data);
    /* free result set */
   // mysqli_free_result($result)

mysqli_close($link);
?>

那么我怎樣才能把這個(gè)文件轉(zhuǎn)換成 Magento 的 MVC 風(fēng)格呢??是否需要將此文件轉(zhuǎn)換為 magento MVC?

So how can I convert this file to Magento's MVC style?? IS this necessary to convert this file to magento MVC?

推薦答案

我認(rèn)為他們要求你做的是轉(zhuǎn)換看起來像這樣的代碼

I think what they are asking you to do, is to convert code that look like

require_once 'path/to/magento'. "/Mage.php";
umask(0);
Mage::app("default");
....

進(jìn)入 Magento MVC(模塊)

In to Magento MVC (module)

appcodelocalMyNamespace

如果您是 OOP 的新手,請看這里:http://www.php.net/manual/en/language.namespaces.rationale.php

If you're new to OOP, take a look here: http://www.php.net/manual/en/language.namespaces.rationale.php

appcodelocalMyNamespaceAppname

新自定義模塊的名稱 - 盡量保持至少首字母大寫,否則 Magento 的理解會出錯(cuò)

Name of new custom module - try to keep at least first letter capital, or there WILL BE truble with Magento's understanding

appcodelocalMyNamespaceAppnameBlock

在經(jīng)典的MVC架構(gòu)中,這代表MVC的View部分

In classic MVC architecture, this represents View part of MVC

appcodelocalMyNamespaceAppnamecontrollers

這相當(dāng)容易理解,如果沒有,玩得開心:http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller

This is fairly easy to understand, if not, have fun: http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller

appcodelocalMyNamespaceAppname etc

包含 Magento MVC 架構(gòu)中最重要的部分——將所有事物連接在一起的 xml 字段

Contains the most significant part in Magento's MVC architecture - the xml field that will connect all things together

appcodelocalMyNamespaceAppnameHelper

適用于包含可重復(fù)例程或簡單程序方法的文件

Intended for files that contain repeatable routines or simple procedural methods

 appcodelocalMyNamespaceAppnameModel

和控制器一樣,看上面的鏈接

Same thing as for controller, take a look at the link above

 appcodelocalMyNamespaceAppnamesql

了解它的用途很有趣,它用于定義自定義數(shù)據(jù)庫表并處理對擴(kuò)展程序的任何升級.

This was interesting thing to find out what's it for, it's to define custom database tables and process any upgrades to your extension.

 etcmodules

包含 Magento 中包含的所有模塊 - 這是我們模塊真正開始的地方

Contains all Modules included in Magento - here's where it all really begins for our module

參見 http://inchoo.net/電子商務(wù)/magento/basic-folder-structure-for-new-magento-module/

這篇關(guān)于如何將獨(dú)立的 PHP 文件轉(zhuǎn)換為 Magento 的 MVC的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 国产精品区二区三区日本 | 97国产一区二区精品久久呦 | 中国美女撒尿txxxxx视频 | 成人三级网址 | 91中文字幕在线 | 亚洲狠狠爱一区二区三区 | 色视频网站在线观看 | 精品一二区 | 国产精品久久久久久久久 | 精品久久久久久亚洲精品 | 综合在线视频 | 韩国电影久久 | 国产精品看片 | 精品久久久久久久久久 | 不卡一区二区三区四区 | 九九在线视频 | 伊人艹| 亚洲精品一区二区网址 | 中文精品视频 | 日韩一级在线 | 久久精品| 久久精品国产亚洲 | 久久久久亚洲 | 亚洲av毛片 | 美日韩精品 | 91精品国产乱码久久久久久久久 | 欧美日韩视频网站 | 国产色网站 | 成人在线一级片 | 国产成人99久久亚洲综合精品 | 中文字幕精品一区二区三区精品 | 午夜午夜精品一区二区三区文 | 亚洲精品资源 | 国产欧美一区二区三区日本久久久 | 欧美国产91| 欧美在线精品一区 | 国产成人免费视频 | 男女视频91 | 欧美久久一区二区三区 | 天天干天天色 | 国产精品成人一区二区三区 |