本文整理匯總了PHP中wpdb::_real_escape方法的典型用法代碼示例。如果您正苦於以下問題:PHP wpdb::_real_escape方法的具體用法?PHP wpdb::_real_escape怎麽用?PHP wpdb::_real_escape使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wpdb
的用法示例。
在下文中一共展示了wpdb::_real_escape方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Constructor
*
* @param array $tables Table names as keys, columns as value arrays
* @param string $from String to find, will be escaped.
* @param string $replacement String to use as replacement, will be escaped.
* @param wpdb $wpdb
*/
public function __construct(array $tables, $from, $replacement, wpdb $wpdb)
{
$this->tables = $tables;
$this->from = $wpdb->_real_escape($from);
$this->replacement = $wpdb->_real_escape($replacement);
$this->wpdb = $wpdb;
}
示例2: search
public function search($word, $orderby = NULL, $order = 'DESC', $limit = '', $select = '*')
{
$word = $this->_wpdb->_real_escape($word);
$orderby = $orderby ? $orderby : $this->_pk;
$query = 'SELECT ' . $select . ' FROM ' . $this->_table();
$where = '';
foreach ($this->_wpdb->get_results('SHOW COLUMNS FROM ' . $this->_table()) as $fieldParam) {
if (stripos($fieldParam->Type, 'text') === FALSE && stripos($fieldParam->Type, 'varchar') === FALSE) {
continue;
}
$where .= ($where ? ' OR ' : ' WHERE ') . $fieldParam->Field . " LIKE '" . $word . "%'";
}
$result = array();
foreach ($this->_wpdb->get_results($query . $where . ' ORDER BY ' . $orderby . ' ' . $order . ' ' . $limit, 'ARRAY_A') as $objectData) {
$className = get_class($this);
$result[] = new $className($objectData);
}
return $result;
}