本文整理汇总了PHP中MDB2::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2::loadFile方法的具体用法?PHP MDB2::loadFile怎么用?PHP MDB2::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2
的用法示例。
在下文中一共展示了MDB2::loadFile方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($answers, $phase)
{
switch ($phase) {
case 'askdb':
if ($answers['yesno'] != 'y') {
$this->_ui->skipParamgroup('init');
}
return true;
break;
case 'init':
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (PEAR::isError($err = MDB2::loadFile('Driver' . DIRECTORY_SEPARATOR . $answers['driver']))) {
PEAR::popErrorHandling();
$this->_ui->outputData('ERROR: Unknown MDB2 driver "' . $answers['driver'] . '": ' . $err->getUserInfo() . '. Be sure you have installed ' . 'MDB2_Driver_' . $answers['driver']);
return false;
}
PEAR::popErrorHandling();
if ($answers['driver'] !== 'mysqli') {
$this->_ui->outputData('pearweb only supports mysqli, ' . 'not ' . $answers['driver']);
return false;
}
return $this->initializeDatabase($answers);
break;
case 'askhttpd':
if ($answers['yesno'] != 'y') {
$this->_ui->skipParamgroup('httpdconf');
}
return true;
break;
case 'httpdconf':
return $this->setupHttpdconf($answers);
break;
}
return true;
}
示例2: array
$stmt = $mdb2->prepare($query, array('text', 'date'), MDB2_PREPARE_MANIP);
if (PEAR::isError($stmt)) {
die($stmt->getMessage());
}
// load Date helper class
MDB2::loadFile('Date');
$stmt->execute(array('name' => 'hello', 'date' => MDB2_Date::mdbToday()));
// get the last inserted id
echo 'last insert id: ';
var_dump($mdb2->lastInsertId($table, 'id'));
$stmt->execute(array('name' => 'world', 'date' => '2005-11-11'));
// get the last inserted id
echo 'last insert id: ';
var_dump($mdb2->lastInsertId($table, 'id'));
// load Iterator implementations
MDB2::loadFile('Iterator');
$query = 'SELECT * FROM ' . $table;
// parameters:
// 1) the query
// 2) true means MDB2 tries to determine the result set type automatically
// 3) true is the default and means that internally a MDB2_Result instance should be created
// 4) 'MDB2_BufferedIterator' means the MDB2_Result should be wrapped inside an SeekableIterator
$result = $mdb2->query($query, true, true, 'MDB2_BufferedIterator');
// iterate over the result set
foreach ($result as $row) {
echo 'output row:<br>';
var_dump($row);
}
// call drop table, since dropTable is not implemented in our instance
// but inside the loaded Manager module __call() will find it there and
// will redirect the call accordingly
示例3: test_loadFile
/**
* Tests that the MDB2::loadFile() method returns the expected
* filename.
*/
function test_loadFile()
{
$filename = 'Extended';
$this->assertEquals('MDB2' . DIRECTORY_SEPARATOR . $filename . '.php', MDB2::loadFile($filename), 'loadFile');
}
示例4:
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* MDB2 container for Authentication
*
* @package LiveUser
* @category authentication
*/
/**
* Require parent class definition and PEAR::MDB2 class.
*/
require_once 'LiveUser/Auth/Common.php';
require_once 'MDB2.php';
MDB2::loadFile('Date');
/**
* Class LiveUser_Auth_Container_MDB2
*
* Description:
* This is a PEAR::MDB2 backend driver for the LiveUser class.
* A PEAR::MDB2 connection object can be passed to the constructor to reuse an
* existing connection. Alternatively, a DSN can be passed to open a new one.
*
* Requirements:
* - File "LoginManager.php" (contains the parent class "LiveUser")
* - Array of connection options or a PEAR::MDB2 connection object must be
* passed to the constructor.
* Example: array('dsn' => 'mysql://user:pass@host/db_name',
* 'connection => &$conn, # PEAR::MDB2 connection object
* 'loginTimeout' => 0,
示例5: installSchema
/**
* Installs table(s)/data schema into database
*
* @access public
* @param string $new_schema New schema file path/name
* @param array $variables Schema variables
* @param string $old_schema Old schema file path/name
* @param string $init_data Schema is include initialization data
* @param string $create If the database should be created
* @return mixed True on success and Jaws_Error on failure
*/
function installSchema($new_schema, $variables = array(), $old_schema = false, $init_data = false, $create = true)
{
MDB2::loadFile('Schema');
$dsn = $this->_dsn;
unset($dsn['database']);
// If the database should be created
$variables['create'] = (int) $create;
// The database name
$variables['database'] = $this->_dsn['database'];
// Prefix of all the tables added
$variables['table_prefix'] = $this->getPrefix();
// set default charset
if (!isset($variables['charset'])) {
$variables['charset'] = $this->getUnicodeCharset();
}
$options = array('debug' => false, 'log_line_break' => '<br />', 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL ^ MDB2_PORTABILITY_FIX_CASE ^ MDB2_PORTABILITY_RTRIM, 'quote_identifier' => true, 'force_defaults' => false);
switch ($this->_dsn['phptype']) {
case 'ibase':
$options['portability'] = $options['portability'] | MDB2_PORTABILITY_FIX_CASE;
$options['database_path'] = empty($this->_db_path) ? JAWS_DATA : $this->_db_path;
break;
case 'oci8':
$options['emulate_database'] = false;
$options['portability'] = $options['portability'] | MDB2_PORTABILITY_FIX_CASE;
break;
case 'sqlite':
$options['database_path'] = empty($this->_db_path) ? JAWS_DATA : $this->_db_path;
break;
case 'mssql':
$options['multibyte_text_field_type'] = $this->Is_FreeTDS_MSSQL_Driver();
break;
}
if ($this->_is_dba) {
$options['DBA_username'] = $this->_dsn['username'];
$options['DBA_password'] = $this->_dsn['password'];
}
if (!isset($this->schema)) {
$this->schema =& MDB2_Schema::factory($this->dbc, $options);
if (MDB2::isError($this->schema)) {
return $this->schema;
}
}
$method = $init_data === true ? 'writeInitialization' : 'updateDatabase';
$result = $this->schema->{$method}($new_schema, $old_schema, $variables);
if (MDB2::isError($result)) {
$this->schema->disconnect();
unset($this->schema);
$GLOBALS['log']->Log(JAWS_ERROR_ERROR, $result->getUserInfo(), 2);
return new Jaws_Error($result->getMessage(), $result->getCode(), JAWS_ERROR_ERROR, 1);
}
return $result;
}
示例6: define
<html>
<body>
';
if (isset($_REQUEST['submit']) && $_REQUEST['file'] != '') {
// BC hack to define PATH_SEPARATOR for version of PHP prior 4.3
if (!defined('PATH_SEPARATOR')) {
if (defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") {
define('PATH_SEPARATOR', ';');
} else {
define('PATH_SEPARATOR', ':');
}
}
ini_set('include_path', '../../' . PATH_SEPARATOR . ini_get('include_path'));
require_once 'MDB2.php';
@(include_once 'Var_Dump.php');
MDB2::loadFile('Tools/Manager');
$dsn = $_REQUEST['type'] . '://' . $_REQUEST['user'] . ':' . $_REQUEST['pass'] . '@' . $_REQUEST['host'] . '/' . $_REQUEST['name'];
$manager =& new MDB2_Tools_Manager();
$err = $manager->connect($dsn, array('debug' => true, 'log_line_break' => '<br>'));
if (MDB2::isError($err)) {
$error = $err->getMessage();
} else {
if ($_REQUEST['action']) {
set_time_limit(0);
}
if ($_REQUEST['action'] == 'dump') {
switch ($_REQUEST['dump']) {
case 'structure':
$dump_what = MDB2_MANAGER_DUMP_STRUCTURE;
break;
case 'content':
示例7: define
// $Id: peardb_wrapper_example.php,v 1.2 2004/04/25 10:05:30 lsmith Exp $
//
// MDB2 test script for the PEAR DB Wrapper.
//
// BC hack to define PATH_SEPARATOR for version of PHP prior 4.3
if (!defined('PATH_SEPARATOR')) {
if (defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") {
define('PATH_SEPARATOR', ';');
} else {
define('PATH_SEPARATOR', ':');
}
}
ini_set('include_path', '../..' . PATH_SEPARATOR . ini_get('include_path'));
require_once 'MDB2.php';
MDB2::loadFile('Wrapper/peardb');
require_once 'Var_Dump.php';
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error');
function handle_pear_error($error_obj)
{
print '<pre><b>PEAR-Error</b><br />';
echo $error_obj->getMessage() . ': ' . $error_obj->getUserinfo();
print '</pre>';
}
// just for kicks you can mess up this part to see some pear error handling
$user = 'metapear';
$pass = 'funky';
//$pass = '';
$host = 'localhost';
$db_name = 'metapear_test_db';
// Data Source Name: This is the universal connection string
示例8: createLOB
//.........这里部分代码省略.........
*
* Integer handle value that specifies a large
* object from which the data to be stored in the
* output file will be written.
*
* result
*
* Integer handle value as returned by the function
* MDB2::query() or MDB2::execute() that specifies
* the result set that contains the large object value
* to be retrieved. If the LOB argument is specified,
* this argument is ignored.
*
* row
*
* Integer value that specifies the number of the
* row of the result set that contains the large
* object value to be retrieved. If the LOB
* argument is specified, this argument is ignored.
*
* field
*
* Integer or string value that specifies the
* number or the name of the column of the result
* set that contains the large object value to be
* retrieved. If the LOB argument is specified,
* this argument is ignored.
*
* binary
*
* Boolean value that specifies whether the large
* object column to be retrieved is of binary type
* (blob) or otherwise is of character type (clob).
* If the LOB argument is specified, this argument
* is ignored.
*
* The following argument is specific of the data
* handler class:
*
* data
*
* String of data that will be returned by the class
* when it requested with the readLOB() method.
*
* The following argument is specific of the resultlob
* handler class:
*
* resultLOB
*
* Integer handle value of a large object result
* row field.
* @return integer handle value that should be passed as argument insubsequent
* calls to functions that retrieve data from the large object input stream.
* @access public
*/
function createLOB($arguments)
{
$db =& $GLOBALS['_MDB2_databases'][$this->db_index];
$result = MDB2::loadFile('LOB');
if (MDB2::isError($result)) {
return $result;
}
$class_name = 'MDB2_LOB';
if (isset($arguments['type'])) {
switch ($arguments['type']) {
case 'data':
break;
case 'resultlob':
$class_name = 'MDB2_LOB_Result';
break;
case 'inputfile':
$class_name = 'MDB2_LOB_Input_File';
break;
case 'outputfile':
$class_name = 'MDB2_LOB_Output_File';
break;
default:
return $db->raiseError('createLOB: ' . $arguments['type'] . ' is not a valid type of large object');
}
} else {
if (isset($arguments['class'])) {
$class = $arguments['class'];
}
}
$lob = count($GLOBALS['_MDB2_LOBs']);
$GLOBALS['_MDB2_LOBs'][] =& new $class_name();
end($GLOBALS['_MDB2_LOBs']);
$lob = key($GLOBALS['_MDB2_LOBs']);
if (isset($arguments['database'])) {
$GLOBALS['_MDB2_LOBs'][$lob]->db =& $arguments['database'];
} else {
$GLOBALS['_MDB2_LOBs'][$lob]->db =& $db;
}
$result = $GLOBALS['_MDB2_LOBs'][$lob]->create($arguments);
if (MDB2::isError($result)) {
$GLOBALS['_MDB2_LOBs'][$lob]->db->datatype->destroyLOB($lob);
return $result;
}
return $lob;
}
示例9: test_loadFile
/**
* Tests that the MDB2::loadFile() method returns the expected
* filename.
* @dataProvider provider
*/
public function test_loadFile($ci)
{
$this->manualSetUp($ci);
$filename = 'Extended';
$this->assertEquals('MDB2' . DIRECTORY_SEPARATOR . $filename . '.php', MDB2::loadFile($filename), 'loadFile');
}
示例10: query
<?php
require_once "../DBInterface.php";
require_once "../ErrorReportEnabler.php";
MDB2::loadFile("Date");
$sql = "SELECT (" . MDB2_Date::mdbNow() . " - " . MDB2_Date::unix2Mdbstamp(strtotime('Jan 18, 2007')) . ")";
print "<p>{$sql}</p>";
$result = query($conn, $sql);
print_r($result->fetchRow());
示例11: array
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
// | Author: Igor Feghali <ifeghali@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: parse.php,v 1.4 2006/08/17 10:57:37 lsmith Exp $
//
#ini_set('include_path', '../../'.PATH_SEPARATOR.ini_get('include_path'));
#ini_set('include_path', '../../../MDB2'.PATH_SEPARATOR.ini_get('include_path'));
require_once 'MDB2.php';
$dsn = array('phptype' => 'mysql', 'username' => 'root', 'password' => '', 'hostspec' => 'localhost');
$options = array();
MDB2::loadFile('Schema');
$manager =& MDB2_Schema::factory($dsn, $options);
if (MDB2::isError($manager)) {
die($manager->getUserinfo());
}
$database_definition = $manager->parseDatabaseDefinitionFile('./schema.xml');
$manager->db->setOption('disable_query', true);
$manager->db->setOption('debug', true);
$manager->writeInitialization($database_definition);
?>
<pre>
<?php
var_dump($database_definition);
var_dump($manager->db->getDebugOutput());
?>
</pre>
示例12: test_loadFile
/**
* Tests that the MDB2::loadFile() method returns the expected
* filename.
*/
function test_loadFile()
{
$filename = 'Extended';
$this->assertEquals('MDB2/' . $filename . '.php', MDB2::loadFile($filename), 'loadFile');
}
示例13: testRequest16970
/**
* Make setOption('result_wrap_class') work without convoluted query() calls
* @see https://pear.php.net/bugs/bug.php?id=16970
* @dataProvider provider
*/
public function testRequest16970($ci)
{
$this->manualSetUp($ci);
$data = $this->populateUserData(1);
$this->db->setFetchMode(MDB2_FETCHMODE_ASSOC);
MDB2::loadFile('Iterator');
switch ($this->db->phptype) {
case 'mysqli':
$expect = 'mysqli_result';
break;
default:
$expect = 'resource';
}
// Regular behavior.
$res = $this->db->query('SELECT * FROM ' . $this->table_users);
$this->assertInstanceOf('MDB2_Result_Common', $res);
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true);
$this->assertInstanceOf('MDB2_Result_Common', $res);
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false);
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true, true);
$this->assertInstanceOf('MDB2_Result_Common', $res);
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true, false);
$this->assertInstanceOf('MDB2_Result_Common', $res);
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true, 'MDB2_BufferedIterator');
$this->assertEquals('MDB2_BufferedIterator', get_class($res));
// Setting third parameter to false forces raw results to be returned.
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false, true);
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false, false);
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false, 'MDB2_BufferedIterator');
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
// Utilize a default result wrap class.
$this->db->setOption('result_wrap_class', 'MDB2_Iterator');
$res = $this->db->query('SELECT * FROM ' . $this->table_users);
$this->assertEquals('MDB2_Iterator', get_class($res));
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true);
$this->assertEquals('MDB2_Iterator', get_class($res));
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false);
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true, true);
$this->assertEquals('MDB2_Iterator', get_class($res));
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true, false);
$this->assertInstanceOf('MDB2_Result_Common', $res);
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, true, 'MDB2_BufferedIterator');
$this->assertEquals('MDB2_BufferedIterator', get_class($res));
// Setting third parameter to false forces raw results to be returned.
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false, true);
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false, false);
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
$res = $this->db->query('SELECT * FROM ' . $this->table_users, null, false, 'MDB2_BufferedIterator');
if ($expect == 'resource') {
$this->assertInternalType('resource', $res);
} else {
$this->assertInstanceOf($expect, $res);
}
}