本文整理汇总了PHP中DataSource::listSources方法的典型用法代码示例。如果您正苦于以下问题:PHP DataSource::listSources方法的具体用法?PHP DataSource::listSources怎么用?PHP DataSource::listSources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::listSources方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _renameTable
/**
* Rename Table method
*
* @param string $type Type of operation to be done, this case 'rename_table'
* @param array $tables List of tables to be renamed
* @return boolean Return true in case of success, otherwise false
* @access protected
*/
protected function _renameTable($type, $tables)
{
foreach ($tables as $oldName => $newName) {
$sources = $this->db->listSources();
if (!in_array($oldName, $sources)) {
throw new MigrationException($this, sprintf(__d('migrations', 'Table "%s" does not exists in database.', true), $oldName));
} else {
if (in_array($newName, $sources)) {
throw new MigrationException($this, sprintf(__d('migrations', 'Table "%s" already exists in database.', true), $newName));
}
}
$sql = 'RENAME TABLE ' . $this->db->fullTableName($oldName) . ' TO ' . $this->db->fullTableName($newName) . ';';
$this->_invokeCallbacks('beforeAction', 'rename_table', array('old_name' => $oldName, 'new_name' => $newName));
if (@$this->db->execute($sql) === false) {
throw new MigrationException($this, sprintf(__d('migrations', 'SQL Error: %s', true), $this->db->error));
}
$this->_invokeCallbacks('afterAction', 'rename_table', array('old_name' => $oldName, 'new_name' => $newName));
}
return true;
}
示例2: listSources
/**
* List available sources
*
* @return array of available CSV files
*/
public function listSources()
{
$this->config['database'] = 'csv';
$cache = parent::listSources();
if ($cache !== null) {
return $cache;
}
$extPattern = '\\.' . preg_quote($this->config['extension']);
if ($this->config['recursive']) {
$list = $this->connection->findRecursive('.*' . $extPattern, true);
foreach ($list as &$item) {
$item = mb_substr($item, mb_strlen($this->config['path'] . DS));
}
} else {
$list = $this->connection->find('.*' . $extPattern, true);
}
foreach ($list as &$item) {
$item = preg_replace('/' . $extPattern . '$/i', '', $item);
}
parent::listSources($list);
unset($this->config['database']);
return $list;
}
示例3: listSources
/**
* Caches/returns cached results for child instances.
*
* @param mixed $data List of tables
* @return array Array of sources available in this datasource
*/
public function listSources($data = null)
{
return parent::listSources($data);
}
示例4: listSources
/**
* listSources
* @param null $data
* @return array|null
*/
public function listSources($data = null)
{
return parent::listSources($data);
// TODO: Change the autogenerated stub
}
示例5: listSources
/**
* Returns an array of sources (tables) in the database.
*
* @param mixed $data
* @return array Array of tablenames in the database
*/
public function listSources($data = null)
{
$cache = parent::listSources();
if ($cache !== null) {
return $cache;
}
}
示例6: listSources
/**
* undocumented function
*
* @return void
* @access public
*/
function listSources($refresh = false)
{
if (!$this->connected() && !$this->login()) {
return false;
}
$cache = parent::listSources();
if (!$refresh && $cache != null) {
return $cache;
}
$sources = array();
$response = $this->Http->get('https://www.google.com/analytics/home/?et=reset&hl=en-US&ns=100');
$optionsRegex = '/<option.+?value="([0-9]+)".*?>([^<]+)<\\/option>/si';
preg_match('/<select.+?name="account_list".*?>(.+?)<\\/select>/is', $response, $accounts);
if (empty($accounts)) {
return false;
}
preg_match_all($optionsRegex, $accounts[1], $accounts, PREG_SET_ORDER);
if (empty($accounts)) {
return false;
}
foreach ($accounts as $i => $account) {
list(, $id, $name) = $account;
if (empty($id) || !is_numeric($id)) {
continue;
}
$account = array('Account' => compact('id', 'name'));
if ($i != 0) {
$response = $this->Http->get('https://www.google.com/analytics/home/admin?scid=' . $id . '&ns=100');
}
preg_match('/<select.+?name="profile_list".*?>(.+?)<\\/select>/is', $response, $profiles);
if (empty($profiles)) {
$account['Profile'] = array();
continue;
}
preg_match_all($optionsRegex, $profiles[1], $profiles, PREG_SET_ORDER);
foreach ($profiles as $profile) {
list(, $id, $name) = $profile;
if (empty($id) || !is_numeric($id)) {
continue;
}
$account['Profile'][] = compact('id', 'name');
}
$sources[] = $account;
}
parent::listSources($sources);
return $sources;
}
示例7: listSources
/**
* Lists all couchdb databases, and caches the response
*
* @param array $data Data to be cached in parent call to DataSource::listSources().
* @return array Array of couchdb sources
* @todo Move URI mangling to DivanSource::uri()
*/
public function listSources($data = null)
{
$cache = parent::listSources($data);
if ($cache != null) {
return $cache;
}
$sources = $this->_decode($this->Socket->get($this->uri() . '_all_dbs'));
parent::listSources($sources);
return $sources;
}