コード例 #1
0
 /**
  * Get last db error
  */
 public function lastError()
 {
     $error = $this->_db->lastError();
     if (!empty($error['err'])) {
         return $error;
     }
     return NULL;
 }
コード例 #2
0
    /**
     * 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
0
ファイル: SQLite.php プロジェクト: JaeHoYun/generatedata
 /**
  * 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
0
    /**
     * 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
0
 /**
  * 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
0
ファイル: email.php プロジェクト: subh/raleigh-workshop-08
 /**
  * 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
0
ファイル: email.php プロジェクト: robksawyer/cakephp2x
 /**
  * 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;
 }