本文整理汇总了PHP中mssql_get_last_message函数的典型用法代码示例。如果您正苦于以下问题:PHP mssql_get_last_message函数的具体用法?PHP mssql_get_last_message怎么用?PHP mssql_get_last_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mssql_get_last_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Database object constructor
* @param string Database host
* @param string Database user name
* @param string Database user password
* @param string Database name
* @param string Common prefix for all tables
*/
function __construct($options)
{
//var_dump_pre($options);
$host = array_key_exists('host', $options) ? $options['host'] : 'localhost';
$user = array_key_exists('user', $options) ? $options['user'] : '';
$password = array_key_exists('password', $options) ? $options['password'] : '';
$database = array_key_exists('database', $options) ? $options['database'] : '';
$prefix = array_key_exists('prefix', $options) ? $options['prefix'] : 'jos_';
$select = array_key_exists('select', $options) ? $options['select'] : true;
// perform a number of fatality checks, then return gracefully
if (!function_exists('mssql_connect')) {
$this->_errorNum = 1;
$this->_errorMsg = 'The MSSQL adapter "mssql" is not available.';
return;
}
// connect to the server
if (!($this->_resource = @mssql_connect($host, $user, $password, true))) {
$this->_errorNum = 2;
$this->_errorMsg = 'Could not connect to MSSQL: ' . mssql_get_last_message();
print_r($this->_resource);
return;
} else {
$this->connected = true;
}
// finalize initializations
parent::__construct($options);
// select the database
if ($select) {
$this->select('[' . $database . ']');
}
}
示例2: SetMSSQLError
function SetMSSQLError($scope, $error)
{
if (($last_error = mssql_get_last_message()) != "") {
$error .= ": " . $last_error;
}
return $this->SetError($scope, $error);
}
示例3: query
public function query($sql)
{
$resource = mssql_query($sql, $this->link);
if ($resource) {
if (is_resource($resource)) {
$i = 0;
$data = array();
while ($result = mssql_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
mssql_free_result($resource);
$query = new stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
unset($data);
return $query;
} else {
return true;
}
} else {
trigger_error('Error: ' . mssql_get_last_message($this->link) . '<br />' . $sql);
exit;
}
}
示例4: initColumns
/**
* Loads the columns for this table.
* @return void
*/
protected function initColumns()
{
include_once 'creole/metadata/ColumnInfo.php';
include_once 'creole/drivers/mssql/MSSQLTypes.php';
if (!@mssql_select_db($this->dbname, $this->conn->getResource())) {
throw new SQLException('No database selected');
}
$res = mssql_query("sp_columns " . $this->name, $this->conn->getResource());
if (!$res) {
throw new SQLException('Could not get column names', mssql_get_last_message());
}
while ($row = mssql_fetch_array($res)) {
$name = $row['COLUMN_NAME'];
$type = $row['TYPE_NAME'];
$length = $row['LENGTH'];
$is_nullable = $row['NULLABLE'];
$default = $row['COLUMN_DEF'];
$precision = $row['PRECISION'];
$scale = $row['SCALE'];
$identity = false;
if (strtolower($type) == "int identity") {
$identity = true;
}
$this->columns[$name] = new ColumnInfo($this, $name, MSSQLTypes::getType($type), $type, $length, $precision, $scale, $is_nullable, $default, $identity);
}
$this->colsLoaded = true;
}
示例5: my_query
function my_query($str_query, $conex)
{
global $conf_db_type, $conf_is_prod;
$queries2log = array('UPD', 'DEL', 'DRO', 'ALT', 'TRU');
if (in_array(strtoupper(substr($str_query, 0, 3)), $queries2log) && !$conf_is_prod) {
@write_log('db_trans', $str_query);
}
switch ($conf_db_type) {
case 'mysql':
$res = @mysql_query($str_query, $conex);
if ($res) {
return $res;
} else {
write_log('db_error', mysql_error() . " ----> " . $str_query);
}
break;
case 'mssql':
$res = @mssql_query($str_query, $conex);
if ($res) {
return $res;
} else {
write_log('db_error', mssql_get_last_message() . " ----> " . $str_query);
}
break;
}
}
示例6: _catch
function _catch($msg = "")
{
if (!($this->error = mssql_get_last_message())) {
return true;
}
$this->error($msg . "<br>{$this->query} \n {$this->error}");
}
示例7: DriverMssqlExec
function DriverMssqlExec($conn, $sql)
{
$result = mssql_query($sql, $conn);
if (!$result) {
throw new lmbDbException('MSSQL execute error happened: ' . mssql_get_last_message() . ". SQL: " . $sql);
}
}
示例8: query
/**
* @param $sql
*
* @return array
*/
public function query($sql)
{
//
$this->connection = $this->getConnection();
// Run query
$query = mssql_query($sql, $this->connection);
// On error
if ($query === false) {
Response::error(500, $_SERVER["SERVER_PROTOCOL"] . ' DB query failed (SQL): ' . mssql_get_last_message());
}
// E.g. boolean is returned if no rows (e.g. no resource found or on UPDATE)
if ($query === true) {
$response = $query;
} else {
// Response
$response = array();
//
// Loop rows and add to response array
if (mssql_num_rows($query) > 0) {
while ($row = mssql_fetch_assoc($query)) {
$response[] = $row;
}
}
// Free the query result
mssql_free_result($query);
}
// Close link
$this->closeConnection();
//
return $response;
}
示例9: dbquery_func_old
function dbquery_func_old($connection_info, $query, $debug = "off")
{
if ($connection_info['db_type'] == "mysql") {
mysql_connect($connection_info['db_host'] . ":" . $connection_info['db_port'], $connection_info['username'], $connection_info['password']) or die("Unable to connect to " . $connection_info['db_host']);
mysql_select_db($connection_info['db_name']) or die("Unable to select database " . $connection_info['db_name']);
$return = mysql_query($query);
if ($debug == "on") {
$merror = mysql_error();
if (!empty($merror)) {
print "MySQL Error:<br />" . $merror . "<p />Query<br />: " . $query . "<br />";
}
print "Number of rows returned: " . mysql_num_rows($return) . "<br />";
}
} else {
if ($connection_info['db_type'] == "mssql") {
mssql_connect($connection_info['db_host'] . "," . $connection_info['db_port'], $connection_info['username'], $connection_info['password']) or die("Unable to connect to " . $connection_info['db_host'] . "<br />" . $query);
mssql_select_db($connection_info['db_name']) or die("Unable to select database " . $connection_info['db_name']);
$return = mssql_query($query);
if ($debug == "on") {
$merror = mssql_get_last_message();
if (!empty($merror)) {
print "MySQL Error: " . $merror . "<br />Query" . $query . "<br />";
}
print "Number of rows returned: " . mssql_num_rows($result) . "<br />";
}
}
}
return $return;
}
示例10: query
public function query($sql)
{
$resource = mssql_query($sql, $this->link);
if ($resource) {
if (is_resource($resource)) {
$i = 0;
$data = array();
while ($result = mssql_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
mssql_free_result($resource);
$query = new Object();
$row = isset(Arrays::first($data)) ? Arrays::first($data) : array();
$query->setRow($row)->setRows($data)->setNumRows($i);
unset($data);
return $query;
} else {
return true;
}
} else {
trigger_error('Error: ' . mssql_get_last_message($this->link) . '<br />' . $sql);
exit;
}
}
示例11: _connect
/**
* Creates a connection resource.
*/
protected function _connect()
{
if (is_resource($this->_connection)) {
// connection already exists
return;
}
if (!extension_loaded('mssql')) {
throw new Exception('The mssql extension is required for this adapter but the extension is not loaded');
}
$serverName = $this->_config['host'];
if (isset($this->_config['port'])) {
$port = (int) $this->_config['port'];
$serverName .= ', ' . $port;
}
$username = $password = '';
if (isset($this->_config['username']) && isset($this->_config['password'])) {
$username = $this->_config['username'];
$password = $this->_config['password'];
}
$this->_connection = mssql_connect($serverName, $username, $password);
if (!$this->_connection) {
throw new Exception('Mssql Connection Error: ' . mssql_get_last_message());
}
if (isset($this->_config['dbname']) && !mssql_select_db($this->_config['dbname'])) {
throw new Exception('Unable to connect or select database ' . $this->_config['dbname']);
}
}
示例12: query
function query($sql){
$res = mssql_query($sql, $this->conn);
if (!$res){
throw new Exception("Query error: " . mssql_get_last_message());
}
return new knjdb_result($this->knjdb, $this, $res);
}
示例13: query
/**
* Executes the SQL query.
* @param string SQL statement.
* @return IDibiResultDriver|NULL
* @throws DibiDriverException
*/
public function query($sql)
{
$this->resultSet = @mssql_query($sql, $this->connection);
// intentionally @
if ($this->resultSet === FALSE) {
throw new DibiDriverException(mssql_get_last_message(), 0, $sql);
}
return is_resource($this->resultSet) ? clone $this : NULL;
}
示例14: throwSQLError
function throwSQLError($message, $query = '')
{
$output = ucfirst($message) . ', the error returned was:<br><br><font color="red">' . mssql_get_last_message();
if ($query != '') {
$output .= '<br>The query I attempted to execute was: ' . $query;
}
$output .= '</font><br><br>';
echo $output . '<br>';
}
示例15: connect
/**
* Connects to the database.
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean TRUE, if connected, otherwise FALSE
*/
function connect($host, $user, $passwd, $db)
{
$this->conn = mssql_pconnect($host, $user, $passwd);
if (empty($db) or $this->conn == false) {
PMF_Db::errorPage(mssql_get_last_message());
die;
}
return mssql_select_db($db, $this->conn);
}