本文整理汇总了PHP中F3::sql方法的典型用法代码示例。如果您正苦于以下问题:PHP F3::sql方法的具体用法?PHP F3::sql怎么用?PHP F3::sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F3
的用法示例。
在下文中一共展示了F3::sql方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_table_exists
function is_table_exists($table, $db = NULL)
{
if (is_null($db)) {
$db = F3::get('DB.name');
}
return $db && F3::sql(array("SELECT COUNT(*) AS found " . "FROM information_schema.tables " . "WHERE table_schema='{$db}' " . "AND table_name='{$table}';"));
}
示例2: normalize_properties_normal
public function normalize_properties_normal($table, $identifier)
{
$all = F3::sql("SELECT * FROM {$table}");
foreach ($all as $row) {
$name = $row[$identifier];
foreach ($row as $key => $column) {
echo "{$name},{$key},{$column}<br>";
}
}
}
示例3: relations
public function relations()
{
// Select magic + class + division
$division = "\n SELECT class, division\n FROM relate_loot_normal\n ";
foreach (F3::sql($division) as $row) {
F3::set('class', F3::get('DB.pdo')->quote($row['class']));
F3::set('division', F3::get('DB.pdo')->quote($row['division']));
$query = "\n UPDATE loot\n SET division = {@division}\n WHERE class = {@class}\n ";
F3::sql($query);
}
}
示例4: kul
<?php
/**
If our database doesn't exist, create our SQLite schema; we'll do it
here programmatically; but this can be done outside of our application
**/
F3::sql(array('CREATE TABLE IF NOT EXISTS kul (' . 'tc INT UNSIGNED NOT NULL,' . 'ad CHAR (15),' . 'soyad CHAR (20),' . 'PRIMARY KEY(tc)' . ');'));
示例5: sync
/**
Synchronize Axon and table structure
@param $_table string
@param $_id string
@public
**/
public function sync($_table, $_id = 'DB')
{
$_db =& F3::$global[$_id];
// Can't proceed until DSN is set
if (!$_db || !$_db['dsn']) {
trigger_error(SQLdb::TEXT_DBConnect);
return;
}
// MySQL schema
if (preg_match('/^mysql\\:/', $_db['dsn'])) {
$_cmd = 'SHOW columns FROM ' . $_table . ';';
$_fields = array('Field', 'Key', 'PRI');
} elseif (preg_match('/^sqlite[2]*\\:/', $_db['dsn'])) {
$_cmd = 'PRAGMA table_info(' . $_table . ');';
$_fields = array('name', 'pk', 1);
} elseif (preg_match('/^(mssql|sybase|dblib|pgsql)\\:/', $_db['dsn'])) {
$_cmd = 'SELECT C.column_name AS field,T.constraint_type AS key ' . 'FROM information_schema.columns C ' . 'LEFT OUTER JOIN information_schema.key_column_usage K ' . 'ON C.table_name=K.table_name AND ' . 'C.column_name=K.column_name ' . 'LEFT OUTER JOIN information_schema.table_constraints T ' . 'ON K.table_name=T.table_name AND ' . 'K.constraint_name=T.constraint_name ' . 'WHERE C.table_name="' . $_table . '";';
$_fields = array('field', 'key', 'PRIMARY KEY');
} else {
trigger_error(self::TEXT_AxonEngine);
return;
}
if (method_exists($this, 'beforeSync')) {
// Execute beforeSync event
$this->beforeSync();
}
$_result = F3::sql($_cmd, $_id, F3::$global['SYNC']);
if (!$_result) {
F3::$global['CONTEXT'] = $_table;
trigger_error(self::TEXT_AxonTable);
return;
}
// Initialize Axon
$this->db = $_id;
$this->table = $_table;
foreach ($_result as $_col) {
// Populate properties
$this->fields[$_col[$_fields[0]]] = NULL;
if ($_col[$_fields[1]] == $_fields[2]) {
// Save primary key
$this->keys[$_col[$_fields[0]]] = NULL;
}
}
$this->empty = TRUE;
if (method_exists($this, 'afterSync')) {
// Execute afterSync event
$this->afterSync();
}
}