本文整理匯總了PHP中DBC::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBC::create方法的具體用法?PHP DBC::create怎麽用?PHP DBC::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBC
的用法示例。
在下文中一共展示了DBC::create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: error_reporting
* the GNU General Public License version 3 license (the "GPLv3"), in which
* case the provisions of the GPLv3 are applicable instead of the above.
*
* @author Tim Kurvers <tim@moonsphere.net>
*/
error_reporting(E_ALL | E_STRICT);
require '../lib/bootstrap.php';
/**
* This example shows how to create a DBC-file from scratch using DBC mappings
*/
// File we'll be using in this example
$file = './dbcs/Sample.dbc';
// Load map from given INI-file (ensure read-access)
$map = DBCMap::fromINI('./maps/Sample.ini');
// Attempt to create a new DBC at given path (ensure write-access) with given map
$dbc = DBC::create($file, $map);
// Adding a single record
$dbc->add(1, 'John', 100, 1.8, 2, 0);
// Adding multiple records in one call
$dbc->add(array(2, 'Tim', 1337, 1.8, 1, 0), array(3, 'Pete', -10, 1.55, 1, 2));
// Failing to match the defined fields in the map (six, in this example) will silently and gracefully continue
// The following will leave 100, 200, 0, 'Hello' out of the actual record
$dbc->add(11, 'I am providing too many fields', 123, 1.2, 0, 0, 100, 200, 0, 'Hello');
// The following will append 0, 0, 0, 0 to the actual record
$dbc->add(12, 'I am providing too little fields');
// Setting up a collection of records
$records = array();
$records[] = array(4, 'Helen', 100, 1.8, 0, 0);
$records[] = array(8, 'Frank', 1337, 1.73, 0, 0);
$records[] = array(10, 'Brad', -10, 1.55, 0, 0);
// Adding a collection of records in bulk