PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of martin barker   Lightweight MVC MySQL SP Class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: demo script
Class: Lightweight MVC MySQL SP Class
Call MySQL stored procedures
Author: By
Last change: Spelling Fix
Date: 11 years ago
Size: 1,280 bytes


Class file image Download
class controller_test extends Controller{
// start the Stored Procedure class
$sql_sp = new models_mysql();
// array of paramaters in the order the stored procedure requires them
$sp_params = array(
// in this example the first field is a OUT param and the name will be used
            // as the name of the value in the select statment that handles the values
array('name' => 'id'),
// this is a standard input parma
array('value' => 'martin'),
// set the stored Procedure name
$sp_name = "getIdByFirstName";
// builds and executes MySQL querys for the givven params and Stored Procedure name
$sql_sp->call($sp_name, $sp_params);
// get method this is a clever little method that allows you to call any of the
        // PHP Core MySQL Functions* using a single method
        // the second argument is required to get any output params provided from the
        // Stored Procedure
        // example of the mysql_fetch_array for a result set from a select
$sql_sp->get('fetch_array', true); // or $sql_sp->get('fetch_array');
        // example of the mysql_fetch_object from the output vars
$sql_sp->get('fetch_object', false);
// * =