本文整理汇总了PHP中Sql::hasColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::hasColumns方法的具体用法?PHP Sql::hasColumns怎么用?PHP Sql::hasColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sql
的用法示例。
在下文中一共展示了Sql::hasColumns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __set
/**
* Overwatches template and query configuration, if it's not either of those, sets it as an option
* @param string $name Name of the property
* @param string $value New value of the property
* @return bool May return false if the template or query configuration weren't successful
*/
public function __set($name, $value)
{
if ($name == 'template') {
$columns = Text::parseStringVar($value);
foreach ($columns as $key => $i) {
if (in_array($i, array_keys($this->vars))) {
unset($columns[$key]);
}
}
if (!Sql::hasColumns($this->table, $value)) {
Kernel::Log('The template uses columns that do not exist on the ' . $this->table . ' table');
return false;
}
} elseif ($name == 'query') {
if (!Sql::testQuery($value)) {
Kernel::Log('The desired query did not run successfully. Please try another one. Your database wasn\'t affected.');
return false;
}
} else {
$this->options[$name] = $value;
}
}
示例2: modifyUser
/**
* Modifies an user's information
* @param string $id_field Field to identify the user with
* @param mixed $fields_mixed Fields to modify. If the value is an array, it must be formatted column => value
* @param string $newvalue New value of the column
* @return bool Returns true if the query was successful
*/
static function modifyUser($id_field, $fields_mixed, $newvalue = null)
{
if (is_array($fields_mixed)) {
if (!Sql::hasColumns('accounts', array_keys($fields_mixed))) {
return false;
}
} else {
if (!Sql::hasColumns('accounts', array($fields_mixed))) {
return false;
}
}
$q = Sql::Update('accounts', array($fields_mixed => $newvalue), 'WHERE ' . self::$id_field . ' = \'' . $id_field . '\'');
return $q;
}