本文整理汇总了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;
}