php table应用,用于 PHP Web 应用程序的 Ajax 简介

创建数据存储

对于此简单的应用程序,您创建一个名为 Composer 的类,该类使业务逻辑可以从 composers 数组包含的条目中检索数据。然后,您创建一个名为 ComposerData 的类,该类使用数组保留作曲家数据。

在 "Projects"(项目)窗口中,右键单击 MyAjaxApp 项目节点,然后选择 "New"(新建)> "PHP Class"(PHP 类)。

将类命名为 Composer,然后单击 "Finish"(完成)。此时会创建该类,并在编辑器中将该类打开。

在该类中粘贴以下代码(更改内容以*粗体*显示)。

class Composer {

*public $id;

public $firstName;

public $lastName;

public $category;

function __construct($id, $firstName, $lastName, $category) {

$this->id = $id;

$this->firstName = $firstName;

$this->lastName = $lastName;

$this->category = $category;

}*

}

?>

创建 ComposerData 类。

在 "Projects"(项目)窗口中,右键单击 MyAjaxApp 项目节点,然后选择 "New"(新建)> "PHP Class"(PHP 类)。

将类命名为 ComposerData,然后单击 "Finish"(完成)。此时会创建该类,并在 IDE 编辑器中将该类打开。

在该类顶部添加 require 语句,以指定该类需要刚创建的 Composer.php 类(更改内容以*粗体*显示)。

*require "Composer.php";*

class ComposerData {

}

在编辑器中,将以下代码粘贴到该类(更改内容以*粗体*显示)。

require "Composer.php";

class ComposerData {

*public $composers;

function __construct() {

$this->composers = array(

new Composer("1", "Johann Sebastian", "Bach", "Baroque"),

new Composer("2", "Arcangelo", "Corelli", "Baroque"),

new Composer("3", "George Frideric", "Handel", "Baroque"),

new Composer("4", "Henry", "Purcell", "Baroque"),

new Composer("5", "Jean-Philippe", "Rameau", "Baroque"),

new Composer("6", "Domenico", "Scarlatti", "Baroque"),

new Composer("7", "Antonio", "Vivaldi", "Baroque"),

new Composer("8", "Ludwig van", "Beethoven", "Classical"),

new Composer("9", "Johannes", "Brahms", "Classical"),

new Composer("10", "Francesco", "Cavalli", "Classical"),

new Composer("11", "Fryderyk Franciszek", "Chopin", "Classical"),

new Composer("12", "Antonin", "Dvorak", "Classical"),

new Composer("13", "Franz Joseph", "Haydn", "Classical"),

new Composer("14", "Gustav", "Mahler", "Classical"),

new Composer("15", "Wolfgang Amadeus", "Mozart", "Classical"),

new Composer("16", "Johann", "Pachelbel", "Classical"),

new Composer("17", "Gioachino", "Rossini", "Classical"),

new Composer("18", "Dmitry", "Shostakovich", "Classical"),

new Composer("19", "Richard", "Wagner", "Classical"),

new Composer("20", "Louis-Hector", "Berlioz", "Romantic"),

new Composer("21", "Georges", "Bizet", "Romantic"),

new Composer("22", "Cesar", "Cui", "Romantic"),

new Composer("23", "Claude", "Debussy", "Romantic"),

new Composer("24", "Edward", "Elgar", "Romantic"),

new Composer("25", "Gabriel", "Faure", "Romantic"),

new Composer("26", "Cesar", "Franck", "Romantic"),

new Composer("27", "Edvard", "Grieg", "Romantic"),

new Composer("28", "Nikolay", "Rimsky-Korsakov", "Romantic"),

new Composer("29", "Franz Joseph", "Liszt", "Romantic"),

new Composer("30", "Felix", "Mendelssohn", "Romantic"),

new Composer("31", "Giacomo", "Puccini", "Romantic"),

new Composer("32", "Sergei", "Rachmaninoff", "Romantic"),

new Composer("33", "Camille", "Saint-Saens", "Romantic"),

new Composer("34", "Franz", "Schubert", "Romantic"),

new Composer("35", "Robert", "Schumann", "Romantic"),

new Composer("36", "Jean", "Sibelius", "Romantic"),

new Composer("37", "Bedrich", "Smetana", "Romantic"),

new Composer("38", "Richard", "Strauss", "Romantic"),

new Composer("39", "Pyotr Il'yich", "Tchaikovsky", "Romantic"),

new Composer("40", "Guiseppe", "Verdi", "Romantic"),

new Composer("41", "Bela", "Bartok", "Post-Romantic"),

new Composer("42", "Leonard", "Bernstein", "Post-Romantic"),

new Composer("43", "Benjamin", "Britten", "Post-Romantic"),

new Composer("44", "John", "Cage", "Post-Romantic"),

new Composer("45", "Aaron", "Copland", "Post-Romantic"),

new Composer("46", "George", "Gershwin", "Post-Romantic"),

new Composer("47", "Sergey", "Prokofiev", "Post-Romantic"),

new Composer("48", "Maurice", "Ravel", "Post-Romantic"),

new Composer("49", "Igor", "Stravinsky", "Post-Romantic"),

new Composer("50", "Carl", "Orff", "Post-Romantic"),

);

}*

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值