Log In
Marshal
Overview
How to model
Modeling resources
How to run
Software
RISE
Overview
Getting Started
Information Modeling
View Modeling
Interface Modeling
Code Generators
MySQL
PostgreSQL
SQL Server
C# (.NET)
PHP for MySQL
PHP for PostgreSQL
AJAX
Visual Studio Development
AJAX Development
Test Your Server
Download
Marshal Software
Marshal Editor
Marshal SQL Utility - FREE
Marshal Archiver
Marshal Integrator
Marshal Repository
RISE Software
RISE Editor - FREE
Visual Studio Extension
Code Generators - FREE
Company
About Us
Home
RISE
RISE
Overview
Product feature list
RISE Visual Modeling
Getting Started
Generate Code
Update your Database
How to get started
Information Modeling
Select drawing mode
Intro to Entity-Relationships
ER for database developers
Information structures
Referencing an entity
Information inheritance
Working with views
Filtering an entity
Flattening out a structure
Using views in views
Using aggregate functions
Adding indexes
Consistency and Refactoring
How to use drawings
How to use stereotypes
How to use colors
Import database schema
How to embed data
Interface Modeling
Basic methods
New method
Delete method
Get method
Set method
List method
Composed methods
Call post-processing
Conditional execution
A basic framework
Transactions
Custom methods
c# custom method
PHP custom method
Handling BLOBs
Listing by relation
Extended queries
User managed methods
Private interfaces
Connection strings
Server security
Code generators
SQL Server code generator
MySQL code generator
PostgreSQL code generator
C-sharp (c#) ODBC code generator
PHP for MySQL code generator
PHP for PostgreSQL code generator
AJAX code generator
Connection strings
Generating code inside RISE
Command-line usage
Standalone usage
Application Development
.NET Visual Studio
CMS - An Example
Windows application
Web application
Javascript AJAX
A JQuery Application
Javascript OO tutorial
Analyze your database
Test your solution
Customization
Presentation conventions
Database conventions
Application conventions
Philosophy of RISE
User Community
Post a Question
Help us Improve
Marshal
Download
r2bsoftware.se
PHP custom method
The sample code in this article is available for
download
.
A PHP custom method implementation needs to meet the following requirements:
The implementation file must be named according to namespace specified in the RISE Editor, i.e.
<namespace>.php
.
The implementation file must contain (implement) the class assigned to the RISE custom method.
The implementation class must provide a constructor. The constructor might have zero arguments, if no database is used in the code or accept a database connection, see samples below.
The implementation class must implement the custom methods, having the same signature (name, arguments and output) as the corrresponding RISE custom methods.
Suppose we create an interface, MyInterface, in a RISE model having prefix MyPrefix. MyInterface is then assigned a method, MyMethod, with a signature according to the picture below.
We also specify, in the RISE Editor, that the method should use the class MyClass in the namespace MyNamespace. Once this is done we generate the interface. The generated code will include (require_once) the file MyNamespace.php and call the method MyMethod. An implementation of this file could look like:
<?php
class MyClass{
public function __construct() {
}
public function MyMethod($a) {
return (object)array("b"=>"MyMethod got " . $a );
}
}
If your model contains an information model (database) that you're interested in accessing from the custom code, the custom code would instead look like:
<?php
class MyClass{
public $conn;
public function __construct($conn) {
$this->conn = $conn;
}
public function MyMethod($a) {
// Do something with $conn
return (object)array("b"=>"MyMethod got " . $a );
}
}
The passed in database connection object,
$conn
above, depends on the database interface used, such as MySQLi. See
PHP database extensions
for further assistance on how to use the connection object.