本文整理汇总了PHP中resource::lastError方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::lastError方法的具体用法?PHP resource::lastError怎么用?PHP resource::lastError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resource
的用法示例。
在下文中一共展示了resource::lastError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lastError
/**
* Get last db error
*/
public function lastError()
{
$error = $this->_db->lastError();
if (!empty($error['err'])) {
return $error;
}
return NULL;
}
示例2: copyCellCollection
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
*
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->_currentCellIsDirty;
$this->_storeData();
// Get a new id for the new table name
$tableName = str_replace('.', '_', $this->_getUniqueID());
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_' . $tableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_' . $this->_TableName)) {
throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));
}
// Copy the existing cell cache file
$this->_TableName = $tableName;
}
示例3: __construct
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->_DBHandle)) {
$this->_TableName = str_replace('.', '_', $this->_getUniqueID());
$_DBName = ':memory:';
$this->_DBHandle = new SQLiteDatabase($_DBName);
if ($this->_DBHandle === false) {
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
}
if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_' . $this->_TableName . ' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
throw new Exception(sqlite_error_string($this->_DBHandle->lastError()));
}
}
}
示例4: logQuery
/**
* logQuery method
*
* Set timers, errors and refer to the parent
* If there are arguments passed - inject them into the query
* Show MongoIds in a copy-and-paste-into-mongo format
*
*
* @param mixed $query
* @param array $args array()
* @return void
* @access public
*/
public function logQuery($query, $args = array()) {
if ($args) {
$this->_stringify($args);
$query = String::insert($query, $args);
}
$this->took = round((microtime(true) - $this->_startTime) * 1000, 0);
$this->affected = null;
if (empty($this->error['err'])) {
$this->error = $this->_db->lastError();
if (!is_scalar($this->error)) {
$this->error = json_encode($this->error);
}
}
$this->numRows = !empty($args['count']) ? $args['count'] : null;
$query = preg_replace('@"ObjectId\((.*?)\)"@', 'ObjectId ("\1")', $query);
return parent::logQuery($query);
}
示例5: array
/**
* Sends out email via SMTP
*
* @return bool Success
* @access private
*/
function _smtp()
{
App::import('Core', array('CakeSocket'));
$defaults = array('host' => 'localhost', 'port' => 25, 'protocol' => 'smtp', 'timeout' => 30);
$this->smtpOptions = array_merge($defaults, $this->smtpOptions);
$this->_getSocket($this->smtpOptions);
if (!$this->__smtpConnection->connect()) {
$this->smtpError = $this->__smtpConnection->lastError();
return false;
} elseif (!$this->_smtpSend(null, '220')) {
return false;
}
$httpHost = env('HTTP_HOST');
if (isset($this->smtpOptions['client'])) {
$host = $this->smtpOptions['client'];
} elseif (!empty($httpHost)) {
list($host) = explode(':', $httpHost);
} else {
$host = 'localhost';
}
if (!$this->_smtpSend("EHLO {$host}", '250') && !$this->_smtpSend("HELO {$host}", '250')) {
return false;
}
if (isset($this->smtpOptions['username']) && isset($this->smtpOptions['password'])) {
$authRequired = $this->_smtpSend('AUTH LOGIN', '334|503');
if ($authRequired == '334') {
if (!$this->_smtpSend(base64_encode($this->smtpOptions['username']), '334')) {
return false;
}
if (!$this->_smtpSend(base64_encode($this->smtpOptions['password']), '235')) {
return false;
}
} elseif ($authRequired != '503') {
return false;
}
}
if (!$this->_smtpSend('MAIL FROM: ' . $this->_formatAddress($this->from, true))) {
return false;
}
if (!is_array($this->to)) {
$tos = array_map('trim', explode(',', $this->to));
} else {
$tos = $this->to;
}
foreach ($tos as $to) {
if (!$this->_smtpSend('RCPT TO: ' . $this->_formatAddress($to, true))) {
return false;
}
}
foreach ($this->cc as $cc) {
if (!$this->_smtpSend('RCPT TO: ' . $this->_formatAddress($cc, true))) {
return false;
}
}
foreach ($this->bcc as $bcc) {
if (!$this->_smtpSend('RCPT TO: ' . $this->_formatAddress($bcc, true))) {
return false;
}
}
if (!$this->_smtpSend('DATA', '354')) {
return false;
}
$header = implode("\r\n", $this->__header);
$message = implode("\r\n", $this->__message);
if (!$this->_smtpSend($header . "\r\n\r\n" . $message . "\r\n\r\n\r\n.")) {
return false;
}
$this->_smtpSend('QUIT', false);
$this->__smtpConnection->disconnect();
return true;
}
示例6: array
/**
* Sends out email via SMTP
*
* @return bool Success
* @access private
*/
function __smtp()
{
App::import('Core', array('Socket'));
$this->__smtpConnection =& new CakeSocket(array_merge(array('protocol' => 'smtp'), $this->smtpOptions));
if (!$this->__smtpConnection->connect()) {
$this->smtpError = $this->__smtpConnection->lastError();
return false;
} elseif (!$this->__smtpSend(null, '220')) {
return false;
}
if (!$this->__smtpSend('HELO cake', '250')) {
return false;
}
if (isset($this->smtpOptions['username']) && isset($this->smtpOptions['password'])) {
if (!$this->__smtpSend('AUTH LOGIN', '334')) {
return false;
}
if (!$this->__smtpSend(base64_encode($this->smtpOptions['username']), '334')) {
return false;
}
if (!$this->__smtpSend(base64_encode($this->smtpOptions['password']), '235')) {
return false;
}
}
if (!$this->__smtpSend('MAIL FROM: ' . $this->__formatAddress($this->from, true))) {
return false;
}
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($this->to, true))) {
return false;
}
foreach ($this->cc as $cc) {
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($cc, true))) {
return false;
}
}
foreach ($this->bcc as $bcc) {
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($bcc, true))) {
return false;
}
}
if (!$this->__smtpSend('DATA', '354')) {
return false;
}
$header = implode("\r\n", $this->__header);
$message = implode("\r\n", $this->__message);
if (!$this->__smtpSend($header . "\r\n\r\n" . $message . "\r\n\r\n\r\n.")) {
return false;
}
$this->__smtpSend('QUIT', false);
$this->__smtpConnection->disconnect();
return true;
}
示例7: __smtp
/**
* Sends out email via SMTP
*
* @return bool Success
* @access private
*/
private function __smtp()
{
App::import('Core', array('CakeSocket'));
$this->__smtpConnection = new CakeSocket(array_merge(array('protocol' => 'smtp'), $this->smtpOptions));
if (!$this->__smtpConnection->connect()) {
$this->smtpError = $this->__smtpConnection->lastError();
return false;
} elseif (!$this->__smtpSend(null, '220')) {
return false;
}
$httpHost = env('HTTP_HOST');
if (isset($this->smtpOptions['client'])) {
$host = $this->smtpOptions['client'];
} elseif (!empty($httpHost)) {
$host = $httpHost;
} else {
$host = 'localhost';
}
if (!$this->__smtpSend("HELO {$host}", '250')) {
return false;
}
if (isset($this->smtpOptions['username']) && isset($this->smtpOptions['password'])) {
$authRequired = $this->__smtpSend('AUTH LOGIN', '334|503');
if ($authRequired == '334') {
if (!$this->__smtpSend(base64_encode($this->smtpOptions['username']), '334')) {
return false;
}
if (!$this->__smtpSend(base64_encode($this->smtpOptions['password']), '235')) {
return false;
}
} elseif ($authRequired != '503') {
return false;
}
}
if (!$this->__smtpSend('MAIL FROM: ' . $this->__formatAddress($this->from, true))) {
return false;
}
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($this->to, true))) {
return false;
}
foreach ($this->cc as $cc) {
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($cc, true))) {
return false;
}
}
foreach ($this->bcc as $bcc) {
if (!$this->__smtpSend('RCPT TO: ' . $this->__formatAddress($bcc, true))) {
return false;
}
}
if (!$this->__smtpSend('DATA', '354')) {
return false;
}
$header = implode("\r\n", $this->__header);
$message = implode("\r\n", $this->__message);
if (!$this->__smtpSend($header . "\r\n\r\n" . $message . "\r\n\r\n\r\n.")) {
return false;
}
$this->__smtpSend('QUIT', false);
$this->__smtpConnection->disconnect();
return true;
}