inetprocess / libsugarcrm
这个库提供了与SugarCRM交互的各种类。
1.2.11
2018-03-01 18:03 UTC
Requires
- php: >=5.3
- psr/log: ~1.0
- symfony/filesystem: ~2
- symfony/finder: ~2
- symfony/process: ^2.8
- symfony/yaml: ~2
Requires (Dev)
- phpunit/dbunit: ~1.3
- phpunit/phpunit: ~4.0
- dev-master
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.22-beta
- 1.1.21-beta
- 1.1.20-beta
- 1.1.19-beta
- 1.1.18-beta
- 1.1.17-beta
- 1.1.16-beta
- 1.1.15-beta
- 1.1.14-beta
- 1.1.13-beta
- 1.1.12-beta
- 1.1.11-beta
- 1.1.10-beta
- 1.1.9-beta
- 1.1.8-beta
- 1.1.7-beta
- 1.1.6-beta
- 1.1.5-beta
- 1.1.4-beta
- 1.1.3-beta
- 1.1.2-beta
- 1.1.1-beta
- 1.1.0-beta
- 1.0.0-beta
- 0.9.1
- 0.9
- dev-langfilecleaner
- dev-wip_rsauvatinet
- dev-code_cleaning
- dev-sugarcli_integration
This package is not auto-updated.
Last update: 2024-09-14 18:20:38 UTC
README
该库允许任何人在应用程序外部与SugarCRM应用程序交互。假设你需要一个导入脚本,每晚运行,具有非常具体的转换或检查集。那么你需要这种工具来能够“登录”SugarCRM,创建或更新豆类,进行SQL查询等...
警告
- 请务必小心,因为Sugar没有做得很“干净”,所以最好关闭PHP的严格标准错误报告,以便使用它。当我运行我的脚本时,我通常这样做:
php -d 'error_reporting=E_ALL & ~E_STRICT' test.php
-
如果你没有在其他类中使用我的类(如果你像下面示例那样直接调用库),请更加小心:不要将你的变量命名为sugar所用的名称,否则你会覆盖它(例如:$db 或 $log)。
-
最后但同样重要的是:你只能实例化Sugar的入口点一次!它使用全局变量,如$GLOBAL['db'],让我来想象如果它被另一个SugarCRM实例覆盖会发生什么吧!
类
Inet\SugarCRM\Application
提供关于SugarCRM安装的一般信息。其他类依赖于这个类。
使用示例
<?php require_once 'vendor/autoload.php'; use Psr\Log\NullLogger; use Inet\SugarCRM\Application; $sugarApp = new Application(new NullLogger(), '/home/sugarcrm/www'); echo $sugarApp->getPath(); if ($sugarApp->isValid()) { echo $sugarApp->getVersion(); }
Inet\SugarCRM\EntryPoint
它说明了Sugar的位置并执行登录SugarCRM的基本步骤。EntryPoint需要一个记录器,因为其他类会记录大量内容。EntryPoint在整个程序中只能加载一次。
使用示例
<?php require_once 'vendor/autoload.php'; use Psr\Log\NullLogger; use Inet\SugarCRM\Application; use Inet\SugarCRM\EntryPoint; if (!EntryPoint::isCreated()) { $nullLogger = new NullLogger; $sugarApp = new Application($nullLogger, '/home/sugarcrm/www'); // enter sugar EntryPoint::createInstance($sugarApp, '1'); } $sugarEP = EntryPoint::getInstance();
Inet\SugarCRM\Bean
最完整的类
- 获取可用模块的列表(getBeansList())
- 获取一个豆类(getBean())
- 创建一个豆类(newBean())
- 获取模块的记录列表(getList())
- ...
使用示例
<?php require_once 'vendor/autoload.php'; use Psr\Log\NullLogger; use Inet\SugarCRM\EntryPoint; use Inet\SugarCRM\Bean; if (!EntryPoint::isCreated()) { $nullLogger = new NullLogger; $sugarApp = new Application($nullLogger, '/home/sugarcrm/www'); // enter sugar EntryPoint::createInstance($sugarApp, '1'); } $sugarEP = EntryPoint::getInstance(); // instanciate the Bean class to retrieve User with id 1 $inetSugarBean = new Bean($sugarEP); $adminUser = $inetSugarBean->getBean('Users', 1); echo $adminUser->name;
Inet\SugarCRM\BeanFactoryCache
不要直接使用它,它由Inet\SugarCRM\Bean直接用于在长循环中清理缓存。
Inet\SugarCRM\DB
用于直接查询SugarCRM数据库。
使用示例
<?php require_once 'vendor/autoload.php'; use Inet\SugarCRM\EntryPoint; use Inet\SugarCRM\DB; // get the DB Class $inetSugarDB = new DB(EntryPoint::getInstance()); $users = $inetSugarDB->query('SELECT * FROM users'); echo count($users);
Inet\SugarCRM\Utils
各种实用工具,用于创建标签、下拉列表、编码或解码多选等...
使用示例
<?php require_once 'vendor/autoload.php'; use Inet\SugarCRM\EntryPoint; use Inet\SugarCRM\Utils; // get the Utils Class $inetSugarUtils = new Utils(EntryPoint::getInstance()); // Convert an array to a multiselect $convertedArray = $inetSugarUtils->arrayToMultiselect(array('test' => 'inet')); echo $convertedArray;
Inet\SugarCRM\SugarQueryIterator
迭代器类,以安全的方式遍历SugarQuery结果。
使用示例:循环记录100到300
<?php $query = new \SugarQuery(); // setup $query $iter = new SugarQueryIterator($query); $iter->setStartOffset(100); foreach ($iter as $id => $bean) { // Do something with $bean if ($iter->getIterationCounter() >= 200) { break; } }