本文整理匯總了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;
}