本文整理汇总了PHP中CSQLDataSource::numRows方法的典型用法代码示例。如果您正苦于以下问题:PHP CSQLDataSource::numRows方法的具体用法?PHP CSQLDataSource::numRows怎么用?PHP CSQLDataSource::numRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSQLDataSource
的用法示例。
在下文中一共展示了CSQLDataSource::numRows方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
/**
* Launches module upgrade process
*
* @param string $oldRevision Revision before upgrade
* @param bool $core_upgrade True if it's a core module upgrade
*
* @return string|null New revision, null on error
*/
function upgrade($oldRevision, $core_upgrade = false)
{
/*if (array_key_exists($this->mod_version, $this->queries)) {
CAppUI::setMsg("Latest revision '%s' should not have upgrade queries", UI_MSG_ERROR, $this->mod_version);
return;
}*/
if (!array_key_exists($oldRevision, $this->queries) && !array_key_exists($oldRevision, $this->config_moves) && !array_key_exists($oldRevision, $this->functions)) {
CAppUI::setMsg("No queries, functions or config moves for '%s' setup at revision '%s'", UI_MSG_WARNING, $this->mod_name, $oldRevision);
return null;
}
// Point to the current revision
reset($this->revisions);
while ($oldRevision != ($currRevision = current($this->revisions))) {
next($this->revisions);
}
$depFailed = false;
do {
// Check for dependencies
foreach ($this->dependencies[$currRevision] as $dependency) {
$module = @CModule::getInstalled($dependency->module);
if (!$module || $module->mod_version < $dependency->revision) {
$depFailed = true;
CAppUI::setMsg("Failed module depency for '%s' at revision '%s'", UI_MSG_WARNING, $dependency->module, $dependency->revision);
}
}
if ($depFailed) {
return $currRevision;
}
// Set Time Limit
if ($this->timeLimit[$currRevision]) {
CApp::setTimeLimit($this->timeLimit[$currRevision]);
}
// Query upgrading
foreach ($this->queries[$currRevision] as $_query) {
list($query, $ignore_errors, $dsn) = $_query;
$ds = $dsn ? CSQLDataSource::get($dsn) : $this->ds;
if (!$ds->exec($query)) {
if ($ignore_errors) {
CAppUI::setMsg("Errors ignored for revision '%s'", UI_MSG_OK, $currRevision);
continue;
}
CAppUI::setMsg("Error in queries for revision '%s': see logs", UI_MSG_ERROR, $currRevision);
return $currRevision;
}
}
// Callback upgrading
foreach ($this->functions[$currRevision] as $function) {
if (!call_user_func($function)) {
$function_name = get_class($function[0]) . "->" . $function[1];
CAppUI::setMsg("Error in function '%s' call back for revision '%s': see logs", UI_MSG_ERROR, $function_name, $currRevision);
return $currRevision;
}
}
// Preferences
foreach ($this->preferences[$currRevision] as $_pref) {
list($_name, $_default, $_restricted) = $_pref;
// Former pure SQL system
// Cannot check against module version or fresh install will generate errors
if (self::isOldPrefSystem($core_upgrade)) {
$query = "SELECT * FROM `user_preferences` WHERE `pref_user` = '0' AND `pref_name` = '{$_name}'";
$result = $this->ds->exec($query);
if (!$this->ds->numRows($result)) {
$query = "INSERT INTO `user_preferences` (`pref_user` , `pref_name` , `pref_value`)\n VALUES ('0', '{$_name}', '{$_default}');";
$this->ds->exec($query);
}
} else {
$pref = new CPreferences();
$where = array();
$where["user_id"] = " IS NULL";
$where["key"] = " = '{$_name}'";
if (!$pref->loadObject($where)) {
$pref->key = $_name;
$pref->value = $_default;
$pref->restricted = $_restricted ? "1" : "0";
$pref->store();
}
}
}
// Config moves
if (count($this->config_moves[$currRevision])) {
foreach ($this->config_moves[$currRevision] as $config) {
CAppUI::setConf($config[1], CAppUI::conf($config[0]));
}
}
} while ($currRevision = next($this->revisions));
return $this->mod_version;
}