我已阅读和阅读有关PHPUnit,SimpleTest和其他单元测试框架的文章.它们听起来都很棒!我终于让PHPUnit与Codeigniter一起工作,感谢https://bitbucket.org/kenjis/my-ciunit/overview
现在我的问题是,我该如何使用它?
我看到的每个教程都有一些抽象的用法,如assertEquals(2, 1+1):
public function testSpeakWithParams()
{
$hello = new SayHello('Marco');
$this->assertEquals("Hello Marco!", $hello->speak());
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个输出这样一个可预测字符串的函数,那就太好了.通常我的应用程序从数据库中获取大量数据,然后在某种表中显示它.那么我该如何测试Codeigniter的控制器呢?
我想做测试驱动开发,我已经阅读了关于PHPUnits网站的教程,但是这个例子再一次看起来很抽象.我的大多数codeigniter函数都在显示数据.
是否有一本书或一本有实际应用的精彩教程和PHPUnit测试的例子?
如何判断MySQL UPDATE成功与实际更新的数据?
例:
TABLE
id city_name
1 Union
2 Marthasville
Run Code Online (Sandbox Code Playgroud)
如果我运行以下内容:
$data = array('city_name', 'Marthasville');
//update record 2 from Marthasville to the same thing, Marthasville.
$this->db->where('id', 2);
$this->db->update('table', $data);
if($this->db->affected_rows() > 0)
{
//I need it to return TRUE when the MySQL was successful even if nothing was actually updated.
return TRUE;
}else{
return FALSE;
}
Run Code Online (Sandbox Code Playgroud)
这将在TRUE每次UPDATE语句成功时返回,但在没有实际更新行时返回FALSE.
TRUE每次成功执行UPDATE语句时,我都需要它返回,即使它实际上没有更改任何记录.
我的问题与用户在2009年10月22日18:31的咨询中发现的答案有关: mysql查询将行数据动态转换为列
似乎Consultuning的答案包含一些带有For Each row循环的MySQL .
你能用For Each RowMySQL 做一个循环吗?
如果是这样,有人可以给我一个MySQL For Each Row文档的链接吗?
我是linux的新手,所以请轻松聊聊慢=)
在Plesk中,我有一些通过SSH访问服务器的选项.我只想连接,添加我的公钥并运行rsync进行备份.
通过SSH访问服务器:
这是Plesk控制面板的图像:

首先,update_batch上的Codeigniter文档不存在.kenjis非常友好地提供一些文档并将其提交到存储库.希望他们很快就拉下来.
有谁知道如何在Codeigniters update_batch命令中添加多个条件?
我想要的用途:
$where = array(
'title',
'name'
);
$this->db->update_batch('mytable', $data, $where);
Run Code Online (Sandbox Code Playgroud)
当我尝试这段代码时,我得到了以下错误:
A Database Error Occurred
One or more rows submitted for batch updating is missing the specified index.
Filename: C:\wamp\www\wheel\system\database\DB_active_rec.php
Line Number: 1451
Run Code Online (Sandbox Code Playgroud)
由kenjis更新批处理文档:
$this->db->update_batch();
Run Code Online (Sandbox Code Playgroud)
根据您提供的数据生成更新字符串,然后运行查询.您可以将数组或对象传递给函数.以下是使用数组的示例:
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name 2' ,
'date' => 'My date 2'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name 2' ,
'date' => 'Another date …Run Code Online (Sandbox Code Playgroud) 我之前使用Tower for Mac来管理我的git存储库。我正在尝试切换为使用PhpStorm管理git repo,但似乎缺少一些功能。
在Tower中,有一个“中止”按钮,使我可以轻松撤消混乱的合并并重新开始。只需单击“中止”按钮,它就可以完美还原所有内容,就像您从未开始过合并一样。
Mac终止塔合并按钮
有没有简单的方法可以在PhpStorm中中止/撤消合并?
好吧,我是CSS的新手,这只会给我带来麻烦.如何将背景颜色添加到多个列而不是所有列.
我想在span2上使用一种背景颜色,在span10上使用不同的颜色.我遇到的问题是填充问题.当我将背景应用于某些列时,内容周围的填充不会很好.这有意义吗?如何使用嵌套列向某些列添加背景并仍保持均匀的填充?
<div class="row bg">
<div class="span10">
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="sidebar">
<div class="hero-unit">
<h1>Join</h1>
<p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-large">Register Now »</a></p>
</div>
</div>
<!-- Example row of columns -->
<div class="row"> …Run Code Online (Sandbox Code Playgroud) 是否有一个小工具可以从Facebook页面获取所有相册和照片,并在我的网站上以简单的网格显示它们?
优选地,小部件将使用PHP,JavaScript或组合.
我有一个客户想要在他们的网站上显示他们的Facebook业务页面上找到的所有图片.我可以手动下载并将每张图片从facebook上传到他的网站,但我认为这是一个使用Facebook的api的好地方.
我有一个脚本,ENTER_FRAME每次都依赖于事件来运行.我注意到在一些较慢的电脑上播放flash电影时会有一些延迟.
是否ENTER_FRAME在每一帧上运行,即使它在慢速计算机上运行?如果flash电影滞后,ENTER_FRAME事件是否仍在运行,渲染只是试图赶上?
ENTER_FRAME每次进入帧时,是否以可靠的方式运行代码来执行代码?
如何在phpMyAdmin或其他程序中看到用于创建视图的原始 MySQL?
我使用的是phpMyAdmin版本3.3.9.
这篇文章讲述了如何查看用于创建视图的SQL,但它不是使用的原始SQL. 如何使用phpMyAdmin 3.2.4编辑视图?
返回的代码有效,它只是没有我的原始格式,使编辑更难.是否有一个程序可以使这更容易,或者我需要将原始SQL保存在某个文本文件中?
使用的SQL:
CREATE VIEW `wheel`.`new_view` AS
SELECT
`t_ci_sessions`.`session_id`,
`t_ci_sessions`.`ip_address`,
`t_ci_sessions`.`user_agent`,
`t_ci_sessions`.`last_activity`,
`t_ci_sessions`.`user_data`
FROM `wheel`.`t_ci_sessions`;
SELECT * FROM `wheel`.`ci_sessions`;
Run Code Online (Sandbox Code Playgroud)
SQL phpMyAdmin返回:
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `new_view` AS select `t_ci_sessions`.`session_id` AS `session_id`,`t_ci_sessions`.`ip_address` AS `ip_address`,`t_ci_sessions`.`user_agent` AS `user_agent`,`t_ci_sessions`.`last_activity` AS `last_activity`,`t_ci_sessions`.`user_data` AS `user_data` from `t_ci_sessions`
Run Code Online (Sandbox Code Playgroud) 那么我做错了什么?当我运行以下代码时,即使事务处于测试模式,数据库也会始终更新.
/**
* update_batch
* This updates multiple rows. The data array must include the game_id and game_type_prize_id
* @param array
* @return bool
* @author zechdc
*/
function update_batch($data)
{
$result = TRUE;
foreach($data as $prize)
{
$this->db->trans_start(TRUE); //first param is set to TRUE for test mode.
$this->db->where('game_id', $prize['game_id']);
$this->db->where('game_type_prize_id', $prize['game_type_prize_id']);
$this->db->update('game_prizes', $prize);
$this->db->trans_complete();
if($this->db->affected_rows() == -1)
{
$result = FALSE;
}
}
return $result;
}
Run Code Online (Sandbox Code Playgroud) 我希望将我服务器上两个目录的内容组合成一个新的zip文件.
示例: 将/ games/wheel/*和/ games/SDK/com/*的内容组合到新zip文件的根目录中.
现有目录结构:
- games
- SDK
- com
- folder1
- file1
- file1
- wheel
- game_file1
- game_file2
Run Code Online (Sandbox Code Playgroud)
新目录结构(解压缩新文件后):
- folder1
- file1
- file2
- game_file1
- game_file2
Run Code Online (Sandbox Code Playgroud)
使用codeigniter的当前Zip库,如何将现有的文件结构组合成一个新的文件结构并压缩它?有没有人扩展它这样做?
codeigniter ×5
php ×5
mysql ×3
activerecord ×2
css ×1
database ×1
facebook ×1
flash-cs5 ×1
git ×1
javascript ×1
macos ×1
phpmyadmin ×1
phpstorm ×1
phpunit ×1
plesk ×1
sql-update ×1
sql-view ×1
ssh ×1
transactions ×1
unit-testing ×1