Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

This example shows us how to PHP with SmartClient framework.

...

  • To install 

     After unzipping the RedBeanPHP, you will see just the rb.php.

    This file contains everything you need to start RedBeanPHP. Just include it in your PHP script like this:

     

    Code Block
    languagephp
        require 'rb.php';

     

    You are now ready to use RedBeanPHP!

  • To setup

    So, you have decided to start with RedBeanPHP. The first thing you need to get started is setting up the database. Luckily this is really easy.

    Code Block
    languagephp
     require('rb.php');
        R::setup('mysql:host=localhost;
            dbname=mydatabase','user','password');
  • Queries

     

    Code Block
    languagephp
    R::getAll( 'select * from supplyitem' );
    Info
    titleNote:

    RedBeanPHP only works with the InnoDB driver for MySQL. MyISAM is toolimited.

...

Code Block
languagehtml/xml
titleindex.html
firstline1
linenumberstrue
<HTML>
<HEAD>
	<SCRIPT>var isomorphicDir = "Scripts/isomorphic/";</SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/system/modules/ISC_Core.js"></SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/system/modules/ISC_Foundation.js"></SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/system/modules/ISC_Containers.js"></SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/system/modules/ISC_Grids.js"></SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/system/modules/ISC_Forms.js"></SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/system/modules/ISC_DataBinding.js"></SCRIPT>
    <SCRIPT SRC="Scripts/isomorphic/skins/TreeFrog/load_skin.js"></SCRIPT>
</HEAD><BODY>
<SCRIPT>
isc.RestDataSource.create({
    ID:"suppyItem",
    fields:[
        {name:"itemID", type:"sequence", hidden:"true", primaryKey:"true"},
        {name:"itemName", type:"text", title:"Item", length:"128", required:"true"},
        {name:"SKU", type:"text", title:"SKU", length:"10", required:"true"},
        {name:"description", type:"text", title:"Description", length:"2000"},
        {name:"category", type:"text", title:"Category", length:"128", required:"true", foreignKey:"supplyCategory.categoryName"},
        {name:"units", type:"enum", title:"Units", length:"5",
            valueMap:["Roll", "Ea", "Pkt", "Set", "Tube", "Pad", "Ream", "Tin", "Bag", "Ctn", "Box"]
        },
        {name:"unitCost", type:"float", title:"Unit Cost", required:"true",
            validators:[
                {type:"floatRange", min:"0", errorMessage:"Please enter a valid (positive) cost"},
                {type:"floatPrecision", precision:"2", errorMessage:"The maximum allowed precision is 2"}
            ]
        },
 
        {name:"inStock", type:"boolean", title:"In Stock"},
        {name:"nextShipment", type:"date", title:"Next Shipment"}
    ],
 
    dataFormat:"json",
    dataURL:"/fetch.php"
 
});
isc.ListGrid.create({
    ID: "suppyItem",
    width: 700, height: 224, alternateRecordStyles: true,
    dataSource: suppyItem,
    autoFetchData: true
});
</SCRIPT>
</BODY></HTML> 

...