Saturday, 15 August 2015

sql server - Execute a MSSQL stored procedure using the PHP PDO class -



sql server - Execute a MSSQL stored procedure using the PHP PDO class -

private function _sp() { $sql = "exec [dbname].[dbo].[sp_name] (?), (?), (?)"; $sql = $this->_dbconn->_dbcon->prepare($sql); //$sql->execute(array($this->_cid, $this->_action_id, $this->_date)); $sql->bindparam(1, $this->_cid, pdo::param_int); $sql->bindparam(2, $this->_action_id, pdo::param_int); $sql->bindparam(3, $this->_date, pdo::param_str); $sql->execute(); //print_r($sql); homecoming $sql; /* foreach($this->_dbconn->_dbcon->query($sql) $row) { echo $row["id"]; } */

i'm struggling execute mssql stored procedure using php pdo class.

the comments indicate various things i've tried can't seem anywhere it.

i've been searching google day doesn't many people combine languages i've combined.

please allow me know if can help, or @ to the lowest degree point me tutorial.

thanks

ok so,

to reply question jonast92,

i'm using in class.

when it's returned, , print_r() @ other end, this:

reports_adv_ajax_errorlogs object ( [_dbconn:reports_adv_ajax_errorlogs:private] => database object ( [_dbcon] => pdo object ( ) ) [_cid:reports_adv_ajax_errorlogs:private] => 4076158 [_action_id:reports_adv_ajax_errorlogs:private] => null [_date:reports_adv_ajax_errorlogs:private] => '09-jun-2014' )

ok,

so reason wasn't working because pdo can't handle mssql datetime info type.

i fixed not binding parameters shown below:

$sql = "exec [dbname].[dbo].[sp_name] $_cid, $_action_id, $_date";

it's not secure particular query didn't need be. wouldn't recommend method select statements.

php sql-server stored-procedures pdo

No comments:

Post a Comment