【问题标题】:Phpfox::getService('user.process')->add($aVals)Phpfox::getService('user.process')->add($aVals)
【发布时间】:2017-12-27 13:42:00
【问题描述】:

我想通过外部 PHP 脚本在 phpfox 框架表 phpfox_user 中插入一些记录

应用reference。从phpfox外部访问php库函数的表phpfox_user中的用户注册以前工作正常。

$iId = Phpfox::getService('user.process')->add($aVals);

// if fine, $iId is ID of user in `phpfox_user` table, otherwise $iId = false.


<?php
echo "This is the beginning."; 
include('auth.php');
include('config1.php');
define('PHPFOX', true); 
define('PHPFOX_DS', DIRECTORY_SEPARATOR); 
define('PHPFOX_DIR', dirname(__FILE__) . PHPFOX_DS); 
define('PHPFOX_START_TIME', array_sum(explode(' ', microtime()))); 
require_once(PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php'); 


    $aVals = array(
'full_name' => 'Naveen Kumart',
'email' => 'testrew@abc.com',
'password' => 'Alobha1',
'gender' => 1, // 1: male 2: female
);

if (Phpfox::getParam('core.registration_enable_dob')) {
// if birthday on registration is required, assign birthday parameters here. I give a sample 1/1/1988
$aVals['month'] = '1'; 
$aVals['day'] = '1';
$aVals['year'] = '1988';


}

$iId = Phpfox::getService('user.process')->add($aVals);

// if fine, $iId is ID of user in `phpfox_user` table, otherwise $iId = false.
if ($iId) {
echo $iId;
} else {
echo 'false';
}

echo "This is the end"; 


?>

【问题讨论】:

  • 什么问题有警告或错误?

标签: php mysql phpfox


【解决方案1】:

如果您使用的是 phpFox V4,请替换:

<?php
echo "This is the beginning."; 
include('auth.php');
include('config1.php');
define('PHPFOX', true); 
define('PHPFOX_DS', DIRECTORY_SEPARATOR); 
define('PHPFOX_DIR', dirname(__FILE__) . PHPFOX_DS); 
define('PHPFOX_START_TIME', array_sum(explode(' ', microtime()))); 
require_once(PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php'); 

define('PHPFOX_PARENT_DIR', __DIR__ . DIRECTORY_SEPARATOR);
define('PHPFOX_NO_RUN', true);
require('./PF.Base/start.php');

如果您的文件与 index.php 不是同一个目录,请更新 PHPFOX_PARENT_DIR

【讨论】:

  • 感谢您的信息,我正在使用版本-核心版本:3.7.6beta1(build 1) PHP 版本:5.6.32-1+ubuntu16.04.1+deb.sury.org+1跨度>
  • 我使用的是 PHPFox 版本 - 3.7.6
  • 能否请您从用户模块服务中发布 add($aVals) 函数。因为我不在我的开发机器附近
猜你喜欢
  • 1970-01-01
  • 2023-04-09
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-31
相关资源
最近更新 更多