Welcome Guest, Not a member yet? Register   Sign In
MSSQL Stored Procedure & Active Record
#8

[eluser]Kamarg[/eluser]
I do something similar to this. It's written from memory since I don't have access to my code at the moment but it should be close enough that you can change it to suit your needs.

Code:
$sql = 'exec stored_proc_name ' . implode(', ', escape($parameter_array));
$return = $this->db->query($sql);

function escape(&$fields, $db = null) {
    $db = is_null($db) ? $this->db : $db;
    $fields = (array) $fields;
        
    if(is_array($fields)) {
        foreach($fields as $k => $v) {
            if(is_numeric($v)) {
                $fields[$k] = $v;
            } else if(is_bool($v)) {
                $fields[$k] = $db->escape($v ? 'True' : 'False');
            } else if(is_null($v)) {
                $fields[$k] = 'NULL';
            } else if(is_string($v)) {
                $fields[$k] = $db->escape($v);
            } else {
                $fields[$k] = $db->escape($v);
            }
        }
    } else {
        return FALSE;
    }
        
    return $fields;
}


Messages In This Thread
MSSQL Stored Procedure & Active Record - by El Forum - 06-30-2010, 08:20 AM
MSSQL Stored Procedure & Active Record - by El Forum - 09-08-2010, 06:28 PM
MSSQL Stored Procedure & Active Record - by El Forum - 09-14-2010, 02:26 AM
MSSQL Stored Procedure & Active Record - by El Forum - 09-14-2010, 06:50 AM
MSSQL Stored Procedure & Active Record - by El Forum - 09-14-2010, 06:59 AM
MSSQL Stored Procedure & Active Record - by El Forum - 09-14-2010, 08:00 AM
MSSQL Stored Procedure & Active Record - by El Forum - 12-10-2010, 03:47 PM
MSSQL Stored Procedure & Active Record - by El Forum - 12-11-2010, 08:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB