本文整理汇总了PHP中DataSource类的典型用法代码示例。如果您正苦于以下问题:PHP DataSource类的具体用法?PHP DataSource怎么用?PHP DataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DataBind
function DataBind()
{
//$this->DataSource = new DataSource();
$ds = new DataSource($this->DataSource);
$ds->DataList = $this->DataSource;
$ds->arrDataColumns = $this->DataColumns;
$this->Data = $ds->GetData($this->DataColumns);
}
示例2: findAll
/**
* Find all DB records and generate array with arrays that filled by records data.
*/
public function findAll($where = '1=1', $limit = null)
{
$sql = 'SELECT * FROM ' . $this->tableName() . ' WHERE ' . $where . ' ' . ($limit !== null ? ' LIMIT ' . $limit : '');
$sth = new DataSource($sql);
$models = array();
while (($model = $sth->getLine()) !== false) {
$models[] = $model;
}
return $models;
}
示例3: handle
private function handle($col)
{
$globalDAO = new GlobalDAO(DataSource::getInstance());
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$content = trim(remove_slashes($_POST['content']));
if ($globalDAO->update($col, $content)) {
$message = array('type' => 'info', 'value' => 'Lưu thành công.');
} else {
$message = array('type' => 'error', 'value' => 'Có lỗi xảy ra!');
}
$this->registry->template->message = $message;
$this->registry->template->content = $content;
$tmp = $globalDAO->select($col);
$this->registry->template->content_backup = $tmp;
} else {
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$tmp = $globalDAO->select($col);
$this->registry->template->content = $tmp;
$this->registry->template->content_backup = $tmp;
}
}
if ($col == 'about') {
$s = '“Giới thiệu”';
} else {
if ($col == 'contact') {
$s = '“Liên hệ”';
}
}
$this->registry->template->tile_title = 'Soạn thảo trang ' . $s;
$this->registry->template->tile_content = 'admin/compose.php';
$this->registry->template->show('admin/layout/admin.php');
}
示例4: getBrands
public function getBrands()
{
$brands = array();
$pdo = DataSource::load();
$data = array();
$statement = 'SELECT brand.*, category.name AS categoryName FROM brand
LEFT JOIN category ON brand.category = category.id
WHERE deleted = 0';
if (!empty($this->categoryId)) {
$statement .= ' AND category = :category';
$data['category'] = $this->categoryId;
}
if ($this->status !== null) {
$statement .= ' AND status = :status';
$data['status'] = $this->status;
}
if (!empty($this->orderBy)) {
$statement .= ' ORDER BY ' . $this->orderBy;
}
if (!empty($this->limit)) {
$statement .= ' LIMIT ' . (int) $this->limit;
}
if (!empty($this->offset)) {
$statement .= ' OFFSET ' . (int) $this->offset;
}
$preparedStatement = $pdo->prepare($statement);
$preparedStatement->execute($data);
$brandsData = $preparedStatement->fetchAll();
foreach ($brandsData as $brandData) {
$brand = new Brand();
$brand->setProperties($brandData);
$brands[] = $brand;
}
return $brands;
}
示例5: index
public function index()
{
if (empty($_GET['seo_url'])) {
$this->notFound();
return;
}
$promoDAO = new PromoDAO(DataSource::getInstance());
$promo = $promoDAO->findBySeoUrl($_GET['seo_url']);
if (!$promo) {
$this->notFound();
return;
}
$categoryDAO = new CatDAO(DataSource::getInstance());
$categories_list = $categoryDAO->findByAll_Navigation();
$cart = getCart();
$this->registry->template->categories_list = $categories_list;
$this->registry->template->cart = $cart;
$this->registry->template->promo_seo_url_newest = $promoDAO->findNewestSeoUrl();
$this->registry->template->is_promo_active = TRUE;
$this->registry->template->promo = $promo;
$this->registry->template->related_promos = $promoDAO->findNewestList();
$this->registry->template->tile_title = $promo['subject'];
$this->registry->template->tile_content = 'promo.php';
$this->registry->template->tile_footer = 'footer.php';
$this->registry->template->show('layout/user.php');
}
示例6: convert
/**
* Source currency
* @param $source
*
* Destination currency
* @param $destination
*
* Amount to convert
* @param $amount
*/
function convert($source, $destination, $amount)
{
$currencies = $this->source->fetch();
if (!isset($currencies[$source])) {
throw new \RuntimeException("Currency not found: {$source}");
}
if (!isset($currencies[$destination])) {
throw new \RuntimeException("Currency not found: {$destination}");
}
return $amount * $currencies[$destination] / $currencies[$source];
}
示例7:
function __construct($config)
{
parent::__construct($config);
$this->api_key = $this->config['api_key'];
$this->username = $this->config['username'];
$this->password = $this->config['password'];
}
示例8: __construct
public function __construct($config = array(), $autoConnect = true)
{
parent::__construct($config);
$config['region'] = $this->region;
$this->S3 = S3Client::factory($config);
$this->bucketName = $config['bucket_name'];
}
示例9: __construct
/**
* Datasource constructor, creates the Configuration, Connection and DocumentManager objects
*
* ### You can pass the following configuration options
*
* - server: name of the server that will be used to connect to Mongo (default: `localhost`)
* - database: name of the database to use when connecting to Mongo (default: `cake`)
* - documentPaths: array containing a list of full path names where Document classes can be located (default: `App::path('Model')`)
* - proxyDir: full path to the directory that will contain the generated proxy classes for each document (default: `TMP . 'cache'`)
* - proxyNamespace: string representing the namespace the proxy classes will reside in (default: `Proxies`)
* - hydratorDir: directory well the hydrator classes will be generated in (default: `TMP . 'cache'`)
* - hydratorNamespace: string representing the namespace the hydrator classes will reside in (default: `Hydrators`)
*
* @param arary $config
* @param boolean $autoConnect whether this object should attempt connection on creation
* @throws MissingConnectionException if it was not possible to connect to MongoDB
*/
public function __construct($config = array(), $autoConnect = true)
{
$modelPaths = $this->_cleanupPaths(App::path('Model'));
$this->_baseConfig = array('proxyDir' => TMP . 'cache', 'proxyNamespace' => 'Proxies', 'hydratorDir' => TMP . 'cache', 'hydratorNamespace' => 'Hydrators', 'server' => 'localhost', 'database' => 'cake', 'documentPaths' => $modelPaths, 'prefix' => null);
foreach (CakePlugin::loaded() as $plugin) {
$this->_baseConfig['documentPaths'] = array_merge($this->_baseConfig['documentPaths'], $this->_cleanupPaths(App::path('Model', $plugin)));
}
parent::__construct($config);
extract($this->config, EXTR_OVERWRITE);
$configuration = new Configuration();
$configuration->setProxyDir($proxyDir);
$configuration->setProxyNamespace($proxyNamespace);
$configuration->setHydratorDir($hydratorDir);
$configuration->setHydratorNamespace($hydratorNamespace);
$configuration->setDefaultDB($database);
$configuration->setMetadataDriverImpl($this->_getMetadataReader($documentPaths));
if (Configure::read('debug') === 0) {
$configuration->setAutoGenerateHydratorClasses(false);
$configuration->setAutoGenerateProxyClasses(false);
$configuration->setMetadataCacheImpl(new ApcCache());
}
$this->configuration = $configuration;
$this->connection = new Connection($server, array(), $configuration);
$this->documentManager = DocumentManager::create($this->connection, $configuration);
$this->documentManager->getEventManager()->addEventListener(array(Events::prePersist, Events::preUpdate, Events::preRemove, Events::postPersist, Events::postUpdate, Events::postRemove), $this);
try {
if ($autoConnect) {
$this->connect();
}
} catch (Exception $e) {
throw new MissingConnectionException(array('class' => get_class($this)));
}
$this->setupLogger();
}
示例10: describe
/**
* Since Datasource has the method `describe()`, it won't be caught `__call()`.
* This ensures it is called on the original datasource properly.
*
* @param mixed $model
* @return mixed
*/
public function describe($model)
{
if (method_exists($this->source, 'describe')) {
return $this->source->describe($model);
}
return $this->describe($model);
}
示例11: HttpSocket
function __construct($config)
{
parent::__construct($config);
$this->Http =& new HttpSocket();
$this->email = $this->config['email'];
$this->password = $this->config['password'];
}
示例12: __construct
/**
* Constructor
* @param array $config An array defining the configuration settings
*/
public function __construct($config)
{
//Construct API version in this to go to SalesforceBaseClass!
parent::__construct($config);
$this->_baseConfig = $config;
$this->connect();
}
开发者ID:richardvella,项目名称:Salesforce-Enterprise-API-CakePHP-2.x-Plugin,代码行数:11,代码来源:SalesforceSource.php
示例13: closeCon
public static function closeCon()
{
if (self::$instance) {
self::$instance->closeSql();
self::$instance = NULL;
}
}
示例14: HttpSocket
function __construct($config)
{
parent::__construct($config);
$this->Http =& new HttpSocket();
$this->username = $this->config['username'];
$this->password = $this->config['password'];
}
示例15: read
public function read(Model $model, $queryData = array(), $recursive = null)
{
parent::read($model, $queryData, $recursive);
$services = array();
if (!empty($queryData['conditions']['servicos'])) {
if (is_array($queryData['conditions']['servicos'])) {
foreach ($queryData['conditions']['servicos'] as $servico) {
$services[] = $this->services[$servico];
}
} else {
$services = $this->services[$queryData['conditions']['servicos']];
}
} else {
// SET DEFAULT FORMAT
$this->format = ECTFormatos::FORMATO_CAIXA_PACOTE;
}
if (!empty($queryData['conditions']['formato'])) {
$this->format = $queryData['conditions']['formato'];
}
// GET VALUES
$return = $this->_getECTValues($queryData['conditions']['altura'], $queryData['conditions']['comprimento'], $queryData['conditions']['largura'], $queryData['conditions']['peso'], $queryData['conditions']['ceporigem'], $queryData['conditions']['cep'], $services, $this->format);
// CONVERTS ARRAY ITERATOR TO ARRAY
$return = iterator_to_array($return, true);
// CONVERT ARRAY OBJECTS TO ARRAY
$return = $this->_toArray($return);
// INSERT MODEL NAME AND RETURNS
return $this->_fixReturn($return);
}