parameter 1 to be string, int given

浏览:303 发布日期:2020/08/14 分类:ThinkPHP6专区 关键字: Builder
错误:strpos() expects parameter 1 to be string, int given
执行在Builder.php 158行。


abstract class CYModel extends Model{
// 开启自动写入时间戳
protected $autoWriteTimestamp = true;
// 关闭自动写入 update_time字段
protected $updateTime = false;

class Products extends CYModel
{
// 原因是我在这里设置了 true
protected $updateTime = true;


官方文档说:
class User extends Model
{
// 关闭自动写入update_time字段
protected $updateTime = false;
}


/**
* 数据分析
* @access protected
* @param Query $query 查询对象
* @param array $data 数据
* @param array $fields 字段信息
* @param array $bind 参数绑定
* @return array
*/
protected function parseData(Query $query, array $data = [], array $fields = [], array $bind = []): array
{
if (empty($data)) {
return [];
}

$options = $query->getOptions();

// 获取绑定信息
if (empty($bind)) {
$bind = $query->getFieldsBindType();
}

if (empty($fields)) {
if ('*' == $options['field']) {
$fields = array_keys($bind);
} else {
$fields = $options['field'];
}
}

$result = [];

foreach ($data as $key => $val) {
$item = $this->parseKey($query, $key, true);

if ($val instanceof Raw) {
$result[$item] = $this->parseRaw($query, $val);
continue;
} elseif (!is_scalar($val) && (in_array($key, (array) $query->getOptions('json')) || 'json' == $query->getFieldType($key))) {
$val = json_encode($val);
}
dump($key); // 在这里报的错,因为设置了 update_time = true
if (false !== strpos($key, '->')) {

最佳答案
评论( 相关
后面还有条评论,点击查看>>