Yii 分割textarea 批量添加
来源:互联网 发布:北京凯恩帝数控编程 编辑:程序博客网 时间:2024/06/16 09:25
1、在\framework\db\CDbCommand.php新加insertSeveral() 方法
第二步:执行添加
<span style="font-size:14px;">/** * @param string $table the table that new rows will be inserted into. * @param array $columns the column data (name=>value) to be inserted into the table. * @return integer number of rows affected by the execution. */ public function insertSeveral($table, $array_columns) { $sql = ''; $params = array(); $i = 0; foreach ($array_columns as $columns) { $names = array(); $placeholders = array(); foreach ($columns as $name => $value) { if (!$i) { $names[] = $this->_connection->quoteColumnName($name); } if ($value instanceof CDbExpression) { $placeholders[] = $value->expression; foreach ($value->params as $n => $v) $params[$n] = $v; } else { $placeholders[] = ':' . $name . $i; $params[':' . $name . $i] = $value; } } if (!$i) { $sql = 'INSERT INTO ' . $this->_connection->quoteTableName($table) . ' (' . implode(', ', $names) . ') VALUES (' . implode(', ', $placeholders) . ')'; } else { $sql .= ',(' . implode(', ', $placeholders) . ')'; } $i++; } return $this->setText($sql)->execute($params); }</span>
第二步:执行添加
<span style="font-size:14px;">$school = new Schoolattr(); $postList = $school->attributes = $_POST['Schoolattr']; $countries_type= $postList['countries_type']; $nameList = explode("\n", $postList['name']); foreach($nameList as $key => $value){ $schooldata['name'] = $value; $schooldata['pid'] = 0; $schooldata['countries_type'] = $countries_type; $schooldata['level'] =1; $command = Yii::app()->db->createCommand(); $command->insert('un_school_attr', $schooldata); } </span>
0 0
- Yii 分割textarea 批量添加
- ajax点击 加号 批量添加 yii框架
- yii gii自动生成的curd添加批量删除实例
- yii 批量修改 批量查询
- Yii 批量删除
- textarea添加信息
- 批量分割Word文档
- PHP分割textarea转回的数据
- 批量添加
- 批量添加
- 批量添加
- yii批量插入的方法
- Yii批量插入的方法
- Yii框架添加FCKeditor
- yii model 添加默认值
- Yii框架添加FCKeditor
- yii model 添加默认值
- yii多级添加
- 生成静态页面ajax实现原理
- poj 3468 A Simple Problem with Integers
- jquery 实现checked 选中与不选中 权限配置 thinkphp
- 关闭浏览器还可以执行程序ignore_user_abort
- Yii 无限分类树
- Yii 分割textarea 批量添加
- ASP.NET项目中,无法引用App_Code中的类
- 使用session实现一次性验证码
- STL 移除性算法的一个特性
- Boost.Asio c++ 网络编程翻译(9)
- 谷歌关于磁盘寿命的分析paper
- Linux 下 tftp 服务配置
- <<Python基础教程>>学习笔记 | 第10章 | 充电时刻
- Makefile 中:= ?= += =的区别