Ignited Datatables调用存储过程php

时间:2013-10-01 07:57:58

标签: codeigniter database-table

我按照教程点燃的数据表https://github.com/IgnitedDatatables/Ignited-Datatables/wiki/Function-Reference

 function datatables() {
    $this->datatables
            ->select('TerminalID,AtmLocation,MaxNumOfBills1,MaxNumOfBills2')
            ->from('terminalset');
    header('Content-Type: application/json');
    echo $this->datatables->generate(); 
    }

当我使用这样的存储过程时遇到麻烦:

$this->db->query('proc_request "$parameter"');

如何在被点燃的数据表中调用存储过程?

如何在库datatables.php中添加查询功能? https://github.com/IgnitedDatatables/Ignited-Datatables/blob/master/application/libraries/Datatables.php

1 个答案:

答案 0 :(得分:0)

你应该这样试试

示例代码:

function GetLogoById($Id)
        {

            $serverName = "XXXXX";
            $uid = "XXXXXX";
            $pwd = "XXXXXX";

            $connectionInfo = array( "UID"=>$uid,
                    "PWD"=>$pwd,
                    "Database"=>"XXXXXX");
            $conn = sqlsrv_connect( $serverName, $connectionInfo);
            $tsql = "select * from TableName where Id = '$Id'";
            $stmt = sqlsrv_query( $conn, $tsql);
            if( $stmt === false)
            {
                echo "Error in query preparation/execution.\n";
                die( print_r( sqlsrv_errors(), true));
            }
            /* Retrieve each row as an associative array and display the results.*/
            while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
            {
                return $row['ColumnName'];
            }
            /* Free statement and connection resources. */
            sqlsrv_free_stmt( $stmt);
            sqlsrv_close( $conn);

        }