PHP code example of shahariaazam / cakephp-datasource-imap
1. Go to this page and download the library: Download shahariaazam/cakephp-datasource-imap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shahariaazam / cakephp-datasource-imap example snippets
//app/Model/CustomEmail.php
class CustomEmail extends AppModel
{
// Important:
public $useDbConfig = 'myCustomEmail';
public $useTable = false;
// Whatever:
public $displayField = 'subject';
public $limit = 10;
// Semi-important:
// You want to use the datasource schema, and still be able to set
// $useTable to false. So we override Cake's schema with that exception:
function schema($field = false)
{
if (!is_array($this->_schema) || $field === true) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
$this->_schema = $db->describe($this, $field);
}
if (is_string($field)) {
if (isset($this->_schema[$field])) {
return $this->_schema[$field];
} else {
return null;
}
}
return $this->_schema;
}
}