问题是这个......
表是这个..
+--------------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+---------+------+-----+---------+----------------+
| facility_map_id | int(10) | NO | PRI | NULL | auto_increment |
| facility_map_facility_id | int(10) | NO | MUL | NULL | |
| facility_map_listing_id | int(10) | NO | | NULL | |
+--------------------------+---------+------+-----+---------+----------------+
Run Code Online (Sandbox Code Playgroud)
这是数据..
+-----------------+--------------------------+-------------------------+
| facility_map_id | facility_map_facility_id | facility_map_listing_id |
+-----------------+--------------------------+-------------------------+
| 248 | 1 | 18 |
| 259 | 1 | 19 |
| 206 …Run Code Online (Sandbox Code Playgroud) 忽略命名空间等任何人都可以解释为什么我不能返回对我的静态数组的引用?实际上,该类是一个 getter 和 setter。我想使用静态方法,因为在整个应用程序生命周期中永远不需要再次实例化该类。
我明白我在做什么可能只是“不好的做法” - 对这件事的更多了解将不胜感激。
namespace xtend\core\classes;
use xtend\core\classes\exceptions;
class registry {
private static $global_registry = array();
private function __construct() {}
public static function add($key, $store) {
if (!isset(self::$global_registry[$key])) {
self::$global_registry[$key] = $store;
} else {
throw new exceptions\invalidParameterException(
"Failed to add the registry. The key $key already exists."
);
}
}
public static function remove($key) {
if (isset(self::$global_registry[$key])) {
unset(self::$global_registry[$key]);
} else {
throw new exceptions\invalidParameterException(
"Cannot remove key $key does not exist in the registry"
); …Run Code Online (Sandbox Code Playgroud) 我可以在注册时添加一个额外的字段.我需要知道的是我需要采取什么步骤来获取输入并将其插入到drupal的用户表中.下面的代码在我的模块中,它只为表单添加一个字段,但是当它提交时它不会对数据做任何事情.
function perscriptions_user($op, &$edit, &$account, $category = NULL){
if ($op == 'register') {
$form['surgery_address'] = array (
'#type' => 'textarea',
'#title' => t('Surgery Address'),
'#required' => TRUE,
);
return $form;
}
if ($op == 'update') {
// …
}
}
Run Code Online (Sandbox Code Playgroud) 我想传递一个函数数组的索引值 - 例如['client_name'] - 第一级值是有效的,因为我可以做
$index = client_name;
function arraything ($index) { return $this->arraytolookat[$index]; }
Run Code Online (Sandbox Code Playgroud)
问题是......如果它是一个多嵌套数组,我该怎么做?
我尝试了eval语句,显然它没有很好地评估括号......所以我尝试了这个.
$index = “[0][‘client_name’]”;
Eval(“$this->arraytolookat$index”);
Run Code Online (Sandbox Code Playgroud)
但它只是失败了...关于一个意想不到的[ - 任何想法?
编辑:我不知道这个函数可能需要多少级别,因此我不能在最后附加一定数量的括号.它不像它看起来那么简单^^
编辑2:基本上 - 我已经编写了一个表单验证工具,其中一个函数返回正确的帖子数据 - 我想要一个简单的方法,当你输入表单元素的名称时 - 它会将POST数据返回给元素,例如getFormData("client_name") - 但是当一个表单变得更复杂时,它可以进入数组,我需要为getFormData("['$ i'] client_name")或者这些行的某些东西做准备,该类中的postdata,以便必须使用该函数.我只是希望该函数采用字符串而不是数组.