本文整理汇总了PHP中Ak::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::db方法的具体用法?PHP Ak::db怎么用?PHP Ak::db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Test_db
function Test_db()
{
require_once AK_CONTRIB_DIR . '/adodb/adodb.inc.php';
$db =& Ak::db();
$this->assertFalse(!$db, 'Connecting to the database. Please check your test_config.php file in order to set up a copy of $dns into $GLOBALS["ak_test_db_dns"]');
$this->assertReference($db, Ak::db(), 'Checking db connection singleton');
}
示例2: Test_db
function Test_db()
{
require_once AK_CONTRIB_DIR . '/adodb/adodb.inc.php';
if (substr($GLOBALS['ak_test_db_dns'], 0, 6) == 'mysql:') {
$GLOBALS['ak_test_db_dns'] = substr_replace($GLOBALS['ak_test_db_dns'], 'mysqlt:', 0, 6);
}
$db =& Ak::db($GLOBALS['ak_test_db_dns']);
$this->assertFalse(!$db, 'Connecting to the database. Please check your test_config.php file in order to set up a copy of $dns into $GLOBALS["ak_test_db_dns"]');
$this->assertReference($db, Ak::db($GLOBALS['ak_test_db_dns']), 'Checking db connection singleton');
}
示例3: AkInstaller
function AkInstaller($db_connection = null)
{
if (empty($db_connection)) {
$this->db =& Ak::db();
} else {
$this->db =& $db_connection;
}
$this->available_tables = $this->getAvailableTables();
$this->db->debug =& $this->debug;
$this->data_dictionary = NewDataDictionary($this->db);
}
示例4: test_all_session_handlers
public function test_all_session_handlers()
{
$cacheHandlers = array('cache_lite' => 1);
if (!Ak::db() instanceof AkSqliteDbAdapter) {
$cacheHandlers['akadodbcache'] = 2;
}
if (AkConfig::getOption('memcached_enabled', false)) {
$cacheHandlers['akmemcache'] = 3;
}
$unitTests = array('_Test_open', '_Test_read_write', '_Test_destroy', '_Test_gc');
foreach ($cacheHandlers as $class => $type) {
foreach ($unitTests as $test) {
$this->{$test}($type, $class);
}
}
}
示例5: createTable
function createTable($table_name, $table_fields, $table_options, $add_sequence_table = true, $table_index_fields = null)
{
if (!isset($this->_db)) {
$db =& Ak::db();
} else {
$db =& $this->_db;
}
$dict = NewDataDictionary($db);
$sqlarray = $dict->CreateTableSQL($table_name, $table_fields, $table_options);
$dict->ExecuteSQLArray($sqlarray);
if (isset($table_index_fields)) {
$sqlarray = $dict->CreateIndexSQL('idx_' . $table_name, $table_name, $table_index_fields);
$dict->ExecuteSQLArray($sqlarray);
}
if ($add_sequence_table) {
$db->CreateSequence('seq_' . $table_name);
}
}
示例6: runFrameworkInstaller
function runFrameworkInstaller()
{
static $unique_dsn = array();
require_once(AK_LIB_DIR.DS.'AkInstaller.php');
require_once(AK_APP_DIR.DS.'installers'.DS.'framework_installer.php');
foreach (array('production', 'development') as $mode){
$dsn = $this->_getDsn($mode);
if(!isset($unique_dsn[$dsn])){
$db_conn =& Ak::db($dsn, $mode);
$installer =& new FrameworkInstaller($db_conn);
$installer->install(null, array('mode' => $mode));
$unique_dsn[$dsn] = true;
}
}
return true;
}
示例7: runFrameworkInstaller
function runFrameworkInstaller()
{
require_once AK_LIB_DIR . DS . 'AkInstaller.php';
require_once AK_APP_DIR . DS . 'installers' . DS . 'framework_installer.php';
foreach (array('development', 'production', 'testing') as $mode) {
$db_conn = Ak::db($this->_getDsn($mode));
$installer = new FrameworkInstaller($db_conn);
$installer->install();
}
return true;
}
示例8: setConnection
/**
* Set the connection for the class.
*/
function setConnection($dns = null, $connection_id = null)
{
$this->_db =& Ak::db($dns, $connection_id);
}
示例9: error_reporting
// | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez |
// | Released under the GNU Lesser General Public License, see LICENSE.txt|
// +----------------------------------------------------------------------+
/**
* @package ActiveSupport
* @subpackage Scripts
* @author Bermi Ferrer <bermi a.t akelos c.om>
* @copyright Copyright (c) 2002-2006, Akelos Media, S.L. http://www.akelos.org
* @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html>
*/
error_reporting(defined('AK_ERROR_REPORTING_ON_SCRIPTS') ? AK_ERROR_REPORTING_ON_SCRIPTS : 0);
require_once AK_LIB_DIR . DS . 'Ak.php';
require_once AK_LIB_DIR . DS . 'AkObject.php';
require_once AK_LIB_DIR . DS . 'AkInflector.php';
require_once AK_LIB_DIR . DS . 'AkPhpParser.php';
defined('AK_SKIP_DB_CONNECTION') && AK_SKIP_DB_CONNECTION ? $dsn = '' : Ak::db(&$dsn);
defined('AK_RECODE_UTF8_ON_CONSOLE_TO') ? null : define('AK_RECODE_UTF8_ON_CONSOLE_TO', false);
require_once AK_LIB_DIR . DS . 'AkActiveRecord.php';
require_once AK_LIB_DIR . DS . 'AkActionMailer.php';
require_once AK_APP_DIR . DS . 'shared_model.php';
require_once AK_LIB_DIR . DS . 'utils' . DS . 'generators' . DS . 'AkelosGenerator.php';
require_once AK_LIB_DIR . DS . 'AkInstaller.php';
if ($id_dir = opendir(AK_MODELS_DIR . DS)) {
while (false !== ($file = readdir($id_dir))) {
if (substr($file, 0, 1) != '.' && $file[0] != '_' && substr($file, -12, 8) != '_service') {
if (!is_dir(AK_MODELS_DIR . DS . $file) && preg_match('/^[a-z0-9_]+\\.php$/', $file)) {
include_once AK_MODELS_DIR . DS . $file;
}
}
}
closedir($id_dir);
示例10: error_reporting
<?php
error_reporting(E_ALL);
defined('AK_ENVIRONMENT') ? null : define('AK_ENVIRONMENT', 'testing');
defined('AK_TEST_DIR') ? null : define('AK_TEST_DIR', str_replace(DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php', '', __FILE__));
defined('AK_APP_DIR') ? null : define('AK_APP_DIR', AK_TEST_DIR . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'app');
defined('AK_PUBLIC_DIR') ? null : define('AK_PUBLIC_DIR', AK_TEST_DIR . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'public');
defined('AK_TEST_HELPERS_DIR') ? null : define('AK_TEST_HELPERS_DIR', AK_TEST_DIR . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'helpers');
define('AK_SITE_URL_SUFFIX', str_replace(array(join(DIRECTORY_SEPARATOR, array_diff((array) @explode(DIRECTORY_SEPARATOR, AK_TEST_DIR), (array) @explode('/', @$_SERVER['REQUEST_URI']))), DIRECTORY_SEPARATOR), array('', '/'), AK_TEST_DIR));
defined('AK_ENABLE_AKELOS_ARGS') ? null : define('AK_ENABLE_AKELOS_ARGS', true);
//define('AK_SKIP_DB_CONNECTION',isset($db) && $db === false);
defined('AK_URL_REWRITE_ENABLED') ? null : define('AK_URL_REWRITE_ENABLED', true);
include_once substr(AK_TEST_DIR, 0, -5) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
defined('AK_APP_LOCALES') ? null : define('AK_APP_LOCALES', 'en,es');
defined('AK_PUBLIC_LOCALES') ? null : define('AK_PUBLIC_LOCALES', AK_APP_LOCALES);
defined('AK_ACTIVE_RECORD_INTERNATIONALIZE_MODELS_BY_DEFAULT') ? null : define('AK_ACTIVE_RECORD_INTERNATIONALIZE_MODELS_BY_DEFAULT', true);
defined('AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS') ? null : define('AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS', true);
defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', rtrim(AK_URL, '/') . '/test/fixtures/public');
defined('AK_TESTING_REWRITE_BASE') ? null : define('AK_TESTING_REWRITE_BASE', false);
defined('AK_LIB_TESTS_DIRECTORY') ? null : define('AK_LIB_TESTS_DIRECTORY', AK_TEST_DIR . DS . 'unit' . DS . 'lib');
if (AK_TESTING_REWRITE_BASE) {
Ak::file_put_contents(AK_BASE_DIR . '/test/fixtures/public/.htaccess', str_replace('# RewriteBase /test/fixtures/public', 'RewriteBase ' . AK_TESTING_REWRITE_BASE, Ak::file_get_contents(AK_BASE_DIR . '/test/fixtures/public/.htaccess')));
}
if (defined('AK_TEST_DATABASE_ON')) {
$default_profile = array_key_exists($argv[count($argv) - 1], $database_settings) ? array_pop($argv) : AK_ENVIRONMENT;
define('AK_DEFAULT_DATABASE_PROFILE', $default_profile);
include_once AK_LIB_DIR . DS . 'Ak.php';
Ak::db();
unset($default_profile);
}
require_once AK_LIB_DIR . DS . 'AkUnitTest.php';
示例11: log
/**
* Log a system message into the database.
*
* @param $type The category to which this message belongs. Usually a model or a controller.
* @param $message The message to store in the log.
* @param $severity The severity of the message. One of the following values:
* - AK_LOG_NOTICE
* - AK_LOG_WARNING
* - AK_LOG_ERROR
* @param $link A link to associate with the message.
*/
function log($type, $message, $severity = AK_LOG_NOTICE, $link = NULL)
{
$DB =& Ak::db();
$DB->debug = true;
/**
* @todo use a function like Ak::get_user_id() to fetch user id and insert it into the log.
* meanwhile we will use user 0;
*/
$user_id = 0;
$sql = "INSERT INTO log ( user_id, type, message, severity, link, location, hostname, created )\n VALUES (" . $user_id . ', ' . $DB->qstr($type) . ', ' . $DB->qstr($message) . ', ' . $severity . ', ' . $DB->qstr($link) . ', ' . $DB->qstr(AK_REQUEST_URI) . ', ' . $DB->qstr($_SERVER['REMOTE_ADDR']) . ', ' . $DB->DBTimeStamp(Ak::time()) . ');';
if ($DB->Execute($sql) === false) {
trigger_error('Error inserting: ' . $DB->ErrorMsg(), E_USER_WARNING);
}
}
示例12: _open
/**
* Session open handler
*
* @access protected
* @return boolean
*/
function _open()
{
$this->_db =& Ak::db();
return true;
}
示例13: dropTables
public function dropTables($tables = array())
{
$installer = new AkInstaller();
if (is_string($tables) && $tables == 'all') {
$tables = Ak::db()->getAvailableTables();
}
foreach ($tables as $table) {
$installer->dropTable($table, array('sequence' => true));
}
}
示例14: file_exists
<?php
# This file is part of the Akelos Framework
# (Copyright) 2004-2010 Bermi Ferrer bermi a t bermilabs com
# See LICENSE and CREDITS for details
$doc_db_file = AK_DOCS_DIR . DS . 'akelos' . DS . 'doc.sqlite';
$installed = file_exists($doc_db_file);
$db = Ak::db('sqlite://' . urlencode($doc_db_file) . '/?persist');
AkConfig::rebaseApp(AK_PLUGINS_DIR . DS . 'doc_builder');
if (!$installed) {
$DocInstaller = new DocInstaller($db);
$DocInstaller->install();
}
$SourceAnalyzer = new SourceAnalyzer();
$SourceAnalyzer->db = $db;
$SourceAnalyzer->storeFilesForIndexing(AK_ACTION_MAILER_DIR);
$SourceAnalyzer->indexFiles();
//unlink($doc_db_file);
return;
$dir_iterator = new RecursiveDirectoryIterator(AK_ACTION_MAILER_DIR);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file) {
if ($file->isFile()) {
echo $file, "\n";
$original_file = file_get_contents($file);
$Reflection = new AkReflectionFile($file);
foreach ($Reflection->getClasses() as $Class) {
echo 'class: ' . $Class->getName() . "\n";
$defined_methods = array('public' => array(), 'protected' => array(), 'private' => array());
foreach ($Class->getMethods() as $Method) {
$name = $Method->getName();
示例15: setConnection
/**
* Set the connection for the class.
*/
function setConnection($dns = null)
{
$this->_db =& Ak::db($dns);
}