本文整理汇总了PHP中false::query方法的典型用法代码示例。如果您正苦于以下问题:PHP false::query方法的具体用法?PHP false::query怎么用?PHP false::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类false
的用法示例。
在下文中一共展示了false::query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dbQuery
/**
* Executes a query on the MySQL server
*
* This executes the passed SQL and returns the recordset or errors out
*
* @param string $sql SQL to be executed
* @param int $ignore_errors If 1 this function supresses any
* error messages
* @return mysqli_result|false Returns results of query
*/
public function dbQuery($sql, $ignore_errors = 0)
{
if ($this->_verbose) {
$this->_errorlog("DEBUG: mysqli - inside database->dbQuery");
$this->_errorlog("DEBUG: mysqli - SQL query is " . $sql);
}
// Run query
if ($ignore_errors) {
$result = @$this->_db->query($sql);
} else {
$result = @$this->_db->query($sql) or trigger_error($this->dbError($sql), E_USER_ERROR);
}
// If OK, return otherwise echo error
if ($this->_db->errno == 0 and $result !== false) {
if ($this->_verbose) {
$this->_errorlog("DEBUG: mysqli - SQL query ran without error");
$this->_errorlog("DEBUG: mysqli - Leaving database->dbQuery");
}
return $result;
} else {
// callee may want to suppress printing of errors
if ($ignore_errors) {
return false;
}
if ($this->_verbose) {
$this->_errorlog("DEBUG: mysqli - SQL caused an error");
$this->_errorlog("DEBUG: mysqli - Leaving database->dbQuery");
}
return false;
}
}
示例2: dbQuery
/**
* Executes a query on the MySQL server
* This executes the passed SQL and returns the recordset or errors out
*
* @param string $sql SQL to be executed
* @param int $ignore_errors If 1 this function supresses any
* error messages
* @return mysqli_result|false Returns results of query
*/
public function dbQuery($sql, $ignore_errors = 0)
{
if ($this->_verbose) {
$this->_errorlog("\n***inside database->dbQuery***");
$this->_errorlog("\n*** sql to execute is {$sql} ***");
}
// Modifies "CREATE TABLE" SQL
if (preg_match('/^\\s*create\\s\\s*table\\s/i', $sql)) {
$p = strrpos($sql, ')');
if ($p !== false) {
$option = substr($sql, $p + 1);
if ($option !== '' && $option !== false) {
// Replaces engine type
$sql = substr($sql, 0, $p + 1);
$option = rtrim($option, " \t\n\r\v;");
$option = str_ireplace('type', 'ENGINE', $option);
if ($this->_use_innodb === true) {
$option = str_ireplace('MyISAM', 'InnoDB', $option);
}
} else {
// Appends engine type
$option = ' ENGINE=' . ($this->_use_innodb === true ? 'InnoDB' : 'MyISAM');
}
// Appends default charset if necessary
if (($this->_charset === 'utf8' || $this->_charset === 'utf8mb4') && !preg_match('/DEFAULT\\s+(CHARSET|CHARACTER\\s+SET)/i', $option)) {
$option .= " DEFAULT CHARSET={$this->_charset}";
}
$sql .= $option;
}
}
// Run query
if ($ignore_errors) {
$result = @$this->_db->query($sql);
} else {
$result = @$this->_db->query($sql);
if ($result === false) {
trigger_error($this->dbError($sql), E_USER_ERROR);
}
}
// If OK, return otherwise echo error
if ($this->_db->errno == 0 && $result !== false) {
if ($this->_verbose) {
$this->_errorlog("\n***sql ran just fine***");
$this->_errorlog("\n*** Leaving database->dbQuery ***");
}
return $result;
} else {
// callee may want to suppress printing of errors
if ($ignore_errors) {
return false;
}
if ($this->_verbose) {
$this->_errorlog("\n***sql caused an error***");
$this->_errorlog("\n*** Leaving database->dbQuery ***");
}
return false;
}
}
示例3: run
/**
* @param string $keyword
* @param int $keywordAdditionalWeight
*/
public function run($keyword, $keywordAdditionalWeight = 0)
{
if ($this->_databaseConnection) {
$prefix = config('coaster::blog.prefix');
$blogPosts = $this->_databaseConnection->query("\n SELECT wp.*, weights.search_weight FROM wp_posts wp RIGHT JOIN\n (\n SELECT ID, sum(search_weight) as search_weight\n FROM (\n SELECT ID, 4 AS search_weight FROM {$prefix}posts WHERE post_type = 'post' AND post_status = 'publish' AND post_title like '%" . $keyword . "%'\n UNION\n SELECT ID, 2 AS search_weight FROM {$prefix}posts WHERE post_type = 'post' AND post_status = 'publish' AND post_content like '%" . $keyword . "%'\n ) results\n GROUP BY ID\n ) weights\n ON weights.ID = wp.ID;\n ");
if ($blogPosts) {
$defaultSeparator = new Path(false);
foreach ($blogPosts as $blogPost) {
$postData = new \stdClass();
$postData->id = 'WP' . $blogPost['ID'];
unset($blogPost['ID']);
foreach ($blogPost as $field => $value) {
$postData->{$field} = $value;
}
$postData->content = $blogPost['post_content'];
$postData->fullName = ucwords(str_replace('/', ' ', config('coaster::blog.url'))) . $defaultSeparator->separator . $blogPost['post_title'];
$postData->fullUrl = config('coaster::blog.url') . $blogPost['post_name'];
self::_addWeight($postData, $blogPost['search_weight'] + $keywordAdditionalWeight);
}
}
}
}