在我的一个控制器类中,我添加了
$this->load->library('session','cart','email_send');
编码部分如下:
var_dump($optionalInfo); // upto this working fine
$this->email_send->activation_link($optionalInfo); // $optionalInfo is an array containing some data
在 email_send类中, activation_link函数 - >我在第一行打印了$ optionalInfo - 但没有得到任何东西。
email_send类和activation_link函数都可以,因为从另一个conrtroller类调用时,相同的函数正常工作。
可能是什么问题?我错过了什么吗?
答案 0 :(得分:1)
像这样加载您的库..
// list the allowed sorting options that will show up in your component
public static $allowedSortingOptions = array(
'created_at asc' => 'Images Created (ascending)',
'created_at desc' => 'Images Created (descending)',
'updated_at asc' => 'Images Updated (ascending)',
// ect....
);
// Scope for your component
public function scopelistImages($query, $options)
{
/*
* Default options
*/
extract(array_merge([
'page' => 1,
'perPage' => 15,
'sort' => 'updated_at',
'category' => null
], $options));
// SORTING
if (!is_array($sort)) {
$sort = [$sort];
}
foreach ($sort as $_sort) {
if (in_array($_sort, array_keys(self::$allowedSortingOptions))) {
$parts = explode(' ', $_sort);
if (count($parts) < 2) {
array_push($parts, 'desc');
}
list($sortField, $sortDirection) = $parts;
if ($sortField == 'random') {
$sortField = Db::raw('RAND()');
}
$query->orderBy($sortField, $sortDirection);
}
}
// Filter by category
........
return $query->paginate($perPage, $page);
}
加载多个库:
$this->load->library(array('session','cart','email_send'));