当前位置: 首页>>代码示例>>PHP>>正文


PHP sqlite_create_function函数代码示例

本文整理汇总了PHP中sqlite_create_function函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlite_create_function函数的具体用法?PHP sqlite_create_function怎么用?PHP sqlite_create_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sqlite_create_function函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ADONewConnection

/**
 * A method to re-initialize connections to the CMSMS configured database.
 * This method should be used by any UDT's or other plugins that use any other method
 * than the standard CMSMS supplied database object to connect to a database.
 *
 */
function &adodb_connect()
{
    global $gCms;
    $config =& $gCms->GetConfig();
    $dbinstance =& ADONewConnection($config['dbms'], 'pear:date:extend:transaction');
    $dbinstance->raiseErrorFn = "adodb_error";
    $conn_func = isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true ? 'PConnect' : 'Connect';
    if (!empty($config['db_port'])) {
        $dbinstance->port = $config['db_port'];
    }
    $connect_result = $dbinstance->{$conn_func}($config['db_hostname'], $config['db_username'], $config['db_password'], $config['db_name']);
    if (FALSE == $connect_result) {
        $str = "Attempt to connect to database {$config['db_name']} on {$config['db_username']}@{$config['db_hostname']} failed";
        trigger_error($str, E_USER_ERROR);
        die($str);
    }
    $dbinstance->raiseErrorFn = null;
    $dbinstance->SetFetchMode(ADODB_FETCH_ASSOC);
    if ($config['debug'] == true) {
        $dbinstance->debug = true;
        #$dbinstance->LogSQL();
    }
    if ($config['dbms'] == 'sqlite') {
        $dbinstance->Execute('PRAGMA short_column_names = 1;');
        sqlite_create_function($config['use_adodb_lite'] ? $db->connectionId : $db->_connectionID, 'now', 'time', 0);
    } else {
        if (!empty($config['default_encoding']) && $config['default_encoding'] == 'utf-8' && $config['set_names'] == true) {
            $dbinstance->Execute("SET NAMES 'utf8'");
        }
    }
    $db =& $dbinstance;
    return $db;
}
开发者ID:rasomu,项目名称:chuza,代码行数:39,代码来源:adodb.functions.php

示例2: _sqlite_add_function

function _sqlite_add_function(&$sqlite, &$f, &$r)
{
    if (_sqlite_is_version(3, $sqlite)) {
        isset($r[1]) ? $sqlite->sqliteCreateFunction($f, $r[0], $r[1]) : $sqlite->sqliteCreateFunction($f, $r[0]);
    } else {
        isset($r[1]) ? sqlite_create_function($sqlite, $f, $r[0], $r[1]) : sqlite_create_function($sqlite, $f, $r[0]);
    }
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:8,代码来源:sqlite_fonctions.php

示例3: registerCallbackFunctions

 /**
  * register sql standard functions for a connection
  *
  * @param   db handel conn
  */
 public function registerCallbackFunctions($conn)
 {
     sqlite_create_function($conn, 'cast', array($this, '_cast'), 2);
     sqlite_create_function($conn, 'sign', array($this, '_sign'), 1);
     sqlite_create_function($conn, 'dateadd', array($this, '_dateadd'), 3);
     sqlite_create_function($conn, 'locate', array($this, '_locate'), 3);
     sqlite_create_function($conn, 'nullif', array($this, '_nullif'), 2);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:13,代码来源:SQLiteDialect.class.php

示例4: _getDB

 /**
  * load the sqlite helper
  */
 function _getDB()
 {
     $db =& plugin_load('helper', 'sqlite');
     if (is_null($db)) {
         msg('The data plugin needs the sqlite plugin', -1);
         return false;
     }
     if ($db->init('data', dirname(__FILE__) . '/db/')) {
         sqlite_create_function($db->db, 'DATARESOLVE', array($this, '_resolveData'), 2);
         return $db;
     } else {
         return false;
     }
 }
开发者ID:rsnitsch,项目名称:dokuwiki-plugin-data,代码行数:17,代码来源:helper.php

示例5: DBConnect

 function DBConnect($dbpath, $dbuname, $dbpass)
 {
     if (defined("DBDEBUG")) {
         $this->debug = constant("DBDEBUG");
     }
     $this->dbpath = $dbpath;
     $this->db = @sqlite_open($dbpath, 0666, $msg_err);
     if (!$this->db) {
         die("<h1>Error connecting to the database!</h1>\n" . "<p>Have you edited dbinit.php and correctly defined " . "the database path?</p>\n");
     }
     sqlite_query($this->db, "PRAGMA synchronous = FULL");
     //we emulate via callback some missing MySQL function
     sqlite_create_function($this->db, "year", "__cb_sqlite_year", 1);
     sqlite_create_function($this->db, "month", "__cb_sqlite_month", 1);
     sqlite_create_function($this->db, "day", "__cb_sqlite_dayofmonth", 1);
     sqlite_create_function($this->db, "dayofmonth", "__cb_sqlite_dayofmonth", 1);
     sqlite_create_function($this->db, "from_unixtime", "__cb_sqlite_from_unixtime");
     sqlite_create_function($this->db, "unix_timestamp", "__cb_sqlite_unix_timestamp");
     sqlite_create_function($this->db, "now", "__cb_sqlite_now");
     sqlite_create_function($this->db, "md5", "__cb_sqlite_md5");
 }
开发者ID:jphpsf,项目名称:gregarius,代码行数:21,代码来源:db.sqlite.php

示例6: initiate

 /**
  * Initializes a database connection.
  * It returns the connection, if successful.
  *
  * @param string $db_server
  * @param string $db_name
  * @param string $db_user
  * @param string $db_passwd
  * @param string $db_prefix
  * @param array $db_options
  *
  * @return resource
  */
 static function initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
 {
     global $db_in_transact, $sqlite_error;
     if (substr($db_name, -3) != '.db') {
         $db_name .= '.db';
     }
     // initialize the instance... if not done already!
     if (self::$_db === null) {
         self::$_db = new self();
     }
     if (!empty($db_options['persist'])) {
         $connection = @sqlite_popen($db_name, 0666, $sqlite_error);
     } else {
         $connection = @sqlite_open($db_name, 0666, $sqlite_error);
     }
     // Something's wrong, show an error if its fatal (which we assume it is)
     if (!$connection) {
         if (!empty($db_options['non_fatal'])) {
             return null;
         } else {
             display_db_error();
         }
     }
     $db_in_transact = false;
     // This is frankly stupid - stop SQLite returning alias names!
     @sqlite_query('PRAGMA short_column_names = 1', $connection);
     // Make some user defined functions!
     sqlite_create_function($connection, 'unix_timestamp', 'elk_udf_unix_timestamp', 0);
     sqlite_create_function($connection, 'inet_aton', 'elk_udf_inet_aton', 1);
     sqlite_create_function($connection, 'inet_ntoa', 'elk_udf_inet_ntoa', 1);
     sqlite_create_function($connection, 'find_in_set', 'elk_udf_find_in_set', 2);
     sqlite_create_function($connection, 'year', 'elk_udf_year', 1);
     sqlite_create_function($connection, 'month', 'elk_udf_month', 1);
     sqlite_create_function($connection, 'dayofmonth', 'elk_udf_dayofmonth', 1);
     sqlite_create_function($connection, 'concat', 'elk_udf_concat');
     sqlite_create_function($connection, 'locate', 'elk_udf_locate', 2);
     sqlite_create_function($connection, 'regexp', 'elk_udf_regexp', 2);
     return $connection;
 }
开发者ID:ahrasis,项目名称:tools,代码行数:52,代码来源:Db-sqlite.class.php

示例7: smf_db_initiate

function smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{
    global $smcFunc, $mysql_set_mode, $db_in_transact, $sqlite_error;
    // Map some database specific functions, only do this once.
    if (!isset($smcFunc['db_fetch_assoc']) || $smcFunc['db_fetch_assoc'] != 'sqlite_fetch_array') {
        $smcFunc += array('db_query' => 'smf_db_query', 'db_quote' => 'smf_db_quote', 'db_fetch_assoc' => 'sqlite_fetch_array', 'db_fetch_row' => 'smf_db_fetch_row', 'db_free_result' => 'smf_db_free_result', 'db_insert' => 'smf_db_insert', 'db_insert_id' => 'smf_db_insert_id', 'db_num_rows' => 'sqlite_num_rows', 'db_data_seek' => 'sqlite_seek', 'db_num_fields' => 'sqlite_num_fields', 'db_escape_string' => 'sqlite_escape_string', 'db_unescape_string' => 'smf_db_unescape_string', 'db_server_info' => 'smf_db_libversion', 'db_affected_rows' => 'smf_db_affected_rows', 'db_transaction' => 'smf_db_transaction', 'db_error' => 'smf_db_last_error', 'db_select_db' => '', 'db_title' => 'SQLite', 'db_sybase' => true, 'db_case_sensitive' => true, 'db_escape_wildcard_string' => 'smf_db_escape_wildcard_string');
    }
    if (substr($db_name, -3) != '.db') {
        $db_name .= '.db';
    }
    if (!empty($db_options['persist'])) {
        $connection = @sqlite_popen($db_name, 0666, $sqlite_error);
    } else {
        $connection = @sqlite_open($db_name, 0666, $sqlite_error);
    }
    // Something's wrong, show an error if its fatal (which we assume it is)
    if (!$connection) {
        if (!empty($db_options['non_fatal'])) {
            return null;
        } else {
            db_fatal_error();
        }
    }
    $db_in_transact = false;
    // This is frankly stupid - stop SQLite returning alias names!
    @sqlite_query('PRAGMA short_column_names = 1', $connection);
    // Make some user defined functions!
    sqlite_create_function($connection, 'unix_timestamp', 'smf_udf_unix_timestamp', 0);
    sqlite_create_function($connection, 'inet_aton', 'smf_udf_inet_aton', 1);
    sqlite_create_function($connection, 'inet_ntoa', 'smf_udf_inet_ntoa', 1);
    sqlite_create_function($connection, 'find_in_set', 'smf_udf_find_in_set', 2);
    sqlite_create_function($connection, 'year', 'smf_udf_year', 1);
    sqlite_create_function($connection, 'month', 'smf_udf_month', 1);
    sqlite_create_function($connection, 'dayofmonth', 'smf_udf_dayofmonth', 1);
    sqlite_create_function($connection, 'concat', 'smf_udf_concat');
    sqlite_create_function($connection, 'locate', 'smf_udf_locate', 2);
    sqlite_create_function($connection, 'regexp', 'smf_udf_regexp', 2);
    return $connection;
}
开发者ID:Kheros,项目名称:MMOver,代码行数:39,代码来源:Subs-Db-sqlite.php

示例8: SQL

 function SQL()
 {
     global $pref;
     $this->type = $pref['sql_type'];
     $this->connect();
     if (DB::isError($this->dbh)) {
         // display custom error message if have problems with dbserver
         if (!$this->dberror($this->dbh->getMessage())) {
             die($this->dbh->getMessage());
         }
     }
     $this->debug = 0;
     // Set some DB engine specific function names
     if ($pref['sql_type'] == 'sqlite') {
         $this->NOW = "datetime('now', 'localtime')";
         $this->CURDATE = "datetime('now', strftime('-%H hours', 'now', 'localtime'), strftime('-%M minutes', 'now', 'localtime'), strftime('-%S seconds', 'now', 'localtime'), 'localtime')";
         // Register some custom functions for sqlite
         // that will emulate some MySQL functions that we use
         sqlite_create_function($this->dbh->connection, 'CONCAT', array('SQL', 'concat'));
     } else {
         $this->NOW = 'NOW()';
         $this->CURDATE = 'CURDATE()';
     }
 }
开发者ID:huluwa,项目名称:zz_atmailopen,代码行数:24,代码来源:SQL.php

示例9: sqlitem_create_function

function sqlitem_create_function($dhb, $function_name, $callback, $num_arg = null)
{
    return sqlite_create_function($dhb, $function_name, $callback, $num_arg);
}
开发者ID:jaketay,项目名称:raspberry_pi,代码行数:4,代码来源:sqlite2.inc.php

示例10: array_map

<?php

array_map('callableString', $array);
call_user_func($array, 'nonCallableString');
//array_map($array, $nonCallableVar);
array_filter($array, array('string', 'string'));
array_reduce(array('string', 'string'), $array);
preg_replace_callback('a', 'b', 'MyClass::myCallbackMethod');
sqlite_create_function('MyClass::myNonCallbackMethod', $b, $c);
sqlite_create_aggregate($a, 'MyClass2::myNonCallbackMethod', $c);
开发者ID:exakat,项目名称:exakat,代码行数:10,代码来源:MarkCallable.01.php

示例11: sqlite_open

<?php

$db = sqlite_open(dirname(__FILE__) . "/db2.sqlite");
/* arguments:
 * 1 database resource
 * 2 sqlite function name
 * 3 php function name
 * 4 number of arguments (optional)
 */
sqlite_create_function($db, "my_date", "date", 2);
/* 
 * The above function makes PHP date() avaliable 
 * from SQLite as my_date() and for highest 
 * performance indicates that it requires 
 * exactly 2 arguments 
 */
$res = sqlite_array_query("\n\tSELECT title, \n\tmy_date((SELECT time_format FROM profile WHERE login='ilia'), timestamp) AS date\n\tFROM messages", $db, SQLITE_ASSOC);
foreach ($res as $v) {
    echo $v['title'] . " was posted on " . $v['date'] . "<br />\n";
}
开发者ID:SandyS1,项目名称:presentations,代码行数:20,代码来源:phpsql.php

示例12: makedb

<?php

require 's_common.inc';
$db = makedb();
$data = array(array("one", "uno"), array("two", "dos"), array("three", "tres"));
sqlite_query("CREATE TABLE strings(a,b)", $db);
function implode_args()
{
    $args = func_get_args();
    $sep = array_shift($args);
    return implode($sep, $args);
}
foreach ($data as $row) {
    sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($row[0]) . "','" . sqlite_escape_string($row[1]) . "')", $db);
}
sqlite_create_function($db, "implode", "implode_args");
$r = sqlite_query("SELECT implode('-', a, b) from strings", $db);
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
    var_dump($row);
}
$r = sqlite_close($db);
?>

开发者ID:jenalgit,项目名称:roadsend-php,代码行数:22,代码来源:zcallbacks.php

示例13: md5rev

    $sql = 'SELECT md5rev(filename) FROM files';
    $rows = sqlite_array_query($dbhandle, $sql);
} else {
    echo 'Error opening sqlite db: ' . $sqliteerror;
    exit;
}
$rows = sqlite_array_query($dbhandle, "SELECT php('md5', filename) from files");
class sqlite_function
{
    function md5($value)
    {
        return md5($value);
    }
}
$dbhandle = sqlite_open('SQLiteDB');
sqlite_create_function($dbhandle, 'md5', array('sqlite_function', 'md5'), 1);
// From now on, you can use md5 function inside your SQL statements
$dbhandle = sqlite_open('mysqlitedb');
$query = sqlite_query($dbhandle, "UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'");
if (!$query) {
    exit('Error in query.');
} else {
    echo 'Number of rows modified: ', sqlite_changes($dbhandle);
}
$dbhandle = new SQLiteDatabase('mysqlitedb');
$query = $dbhandle->query("UPDATE users SET email='jDoe@example.com' WHERE username='jDoe'");
if (!$query) {
    exit('Error in query.');
} else {
    echo 'Number of rows modified: ', $dbhandle->changes();
}
开发者ID:469306621,项目名称:Languages,代码行数:31,代码来源:sqlite.php

示例14: addFunction

 /**
  * This method expand the SQLite ability
  *
  * The functions added with this method, can be used in the sql query.
  * The functgion of PHP, they can be called with the sintax:
  * php('functionName', param, param, ...)
  *
  * @param	string		$name				name of SQLite function
  * @param	string		$originalFunction	name of the original funtion to call
  * @param	int			$args				number of aguments
  * @access	public
  * @return	void
  */
 function addFunction($name, $originalFunction, $args)
 {
     sqlite_create_function($this->_conn, $name, $originalFunction, $args);
 }
开发者ID:michaelprem,项目名称:phc,代码行数:17,代码来源:SPSQLite.class.php

示例15: connect

 static function connect($dsn, $debug = false, $die = true, $prefix = null, $make_global = true)
 {
     /*
     $gCms = silk();
     $persistent = false;
     
     if ($dbms == '')
     {
     	$config = cms_config();
     	$dbms = $config['dbms'];
     	$hostname = $config['db_hostname'];
     	$username = $config['db_username'];
     	$password = $config['db_password'];
     	$dbname = $config['db_name'];
     	$debug = $config['debug'];
     	$persistent = $config['persistent_db_conn'];
     }
     */
     if ($prefix !== null) {
         self::$prefix = $prefix;
     }
     $dbinstance = null;
     $_GLOBALS['ADODB_CACHE_DIR'] = join_path(ROOT_DIR, 'tmp', 'cache');
     require_once join_path(SILK_LIB_DIR, 'adodb', 'adodb-exceptions.inc.php');
     require_once join_path(SILK_LIB_DIR, 'adodb', 'adodb.inc.php');
     try {
         $dbinstance = ADONewConnection($dsn);
         $dbinstance->fnExecute = 'count_execs';
         $dbinstance->fnCacheExecute = 'count_cached_execs';
     } catch (exception $e) {
         if ($die) {
             echo "<strong>Database Connection Failed</strong><br />";
             echo "Error: {$dbinstance->_errorMsg}<br />";
             echo "Function Performed: {$e->fn}<br />";
             echo "Host/DB: {$e->host}/{$e->database}<br />";
             die;
         } else {
             return null;
         }
     }
     $dbinstance->SetFetchMode(ADODB_FETCH_ASSOC);
     $dbinstance->debug = $debug;
     if (isset($dbms) && $dbms == 'sqlite') {
         $dbinstance->Execute("PRAGMA short_column_names = 1;");
         sqlite_create_function($dbinstance->_connectionID, 'now', 'time', 0);
     }
     if ($make_global) {
         self::$instance = $dbinstance;
     }
     //Initialize the CMS_DB_PREFIX define
     self::get_prefix();
     return $dbinstance;
 }
开发者ID:JackSpratt,项目名称:silk,代码行数:53,代码来源:class.silk_database.php


注:本文中的sqlite_create_function函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。