本文整理汇总了PHP中DBConnection::get_table_columns_names方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::get_table_columns_names方法的具体用法?PHP DBConnection::get_table_columns_names怎么用?PHP DBConnection::get_table_columns_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::get_table_columns_names方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Create an empty model class instance that corresponds to a table in the
* database. For all columns there will be getters and setters (magic methods).
* With the instance you will be able to fetch/change data from the database.
* @param string $className The model class you wish to create.
*/
public function __construct($className)
{
$this->className = $className;
$db = new DBConnection();
$columns = $db->get_table_columns_names($this->convert_to_table_name($className));
foreach ($columns as $c) {
$this->classFields[$c] = null;
}
// Ignore: it's for debugging purposes. Used in to_dump() method.
ModelTemplate::$currentInstanceId++;
$this->instanceId = ModelTemplate::$currentInstanceId;
}
示例2: array
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
echo '<p> Some columns: ';
var_dump($db->select('truck', array('brand', 'age'), 'id', $lastInsertedId));
echo '</p>';
/*
* SELECT ALL TEST.
*/
$db->insert('truck', array('brand' => 'Mercedes', 'age' => 3));
echo '<p> All rows and columns: ';
var_dump($db->select('truck', '*'));
/*
* UPDATE TEST.
*/
echo '<p> Before update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
$db->update('truck', array('vehicle_capacity' => 0, 'brand' => 'MAN', 'age' => 0), $lastInsertedId);
echo '<p> After update: ';
var_dump($db->select('truck', '*', 'id', $lastInsertedId));
echo '</p>';
/*
* DELETE TEST.
*/
echo '<p> Deleted rows: ' . $db->delete('truck', $lastInsertedId) . '</p>';
echo '<p> Deleted rows: ' . $db->delete('truck', $lastInsertedId + 1) . '</p>';
/*
* GET TABLE COLUMNS NAMES TEST.
*/
var_dump($db->get_table_columns_names('truck'));