我有两张桌子:
regions <id>
points <region_id, x, y>
Run Code Online (Sandbox Code Playgroud)
假设每个区域恰好有4个点,并且这些点描述了一个矩形 - 是否有一个SQL查询将带给我这个视图:
rectangular_regions <region_id, x1, y1, x2, y2>
Run Code Online (Sandbox Code Playgroud)
?
我在我的控制器中有这个代码
class Upload_center extends Controller
{
function __construct()
{
parent::Controller();
$this->load->model('auth_model') ;
if(!$this->auth_model->authorize())
{
redirect('login');
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的视图中有这个代码
$('#swfupload-control').swfupload({
upload_url: "<?=base_url()?>index.php/upload_center/upload",
file_post_name: 'fileupload',
file_size_limit : "200000000",
file_types : "*.zip;*.rar;*.pdf;*.doc;*.docx;*.mp3;*.avi;*.wmv;*.docx;*.jpg;*.jpeg;*.JPG;*.JPEG;*.png;*.gif;*.bitmap;",
file_types_description : "zip files ",
post_params: {"PHPSESSID": "<?=$this->session->userdata('session_id');?>"} ,
file_upload_limit : 1,
flash_url : "<?=base_url()?>js/jquery-swfupload/js/swfupload/swfupload.swf",
button_image_url : '<?=base_url()?>js/jquery-swfupload/js/swfupload/wdp_buttons_upload_114x29.png',
button_width : 114,
button_height : 29,
button_placeholder : $('#button')[0],
debug: false
Run Code Online (Sandbox Code Playgroud)
我希望用户在登录后上传他们的文件,所以我有一个方法需要用户登录才能继续上传文件.虽然我在我的视图中使用了flash uploader,但我认为它没有传递会话值,而且PHP认为用户没有登录并且将其重定向到登录页面.我phpsessionid通过邮寄发送但仍然没有.
我知道强烈建议在与文件系统分离时运行单元测试,因为如果你在测试中触摸文件系统,你也可以测试文件系统本身.好的,这是合理的.
我的问题是,如果我想测试文件保存到磁盘,我该怎么办?与数据库一样,我将一个负责数据库访问的接口分开,然后为我的测试创建另一个实现?或者可能还有其他方式?
我需要用Java开发一个程序来解决一些积分问题.像这样的积分:

我在java.Math中寻找了一些函数来做到这一点,但我没有找到任何东西.
有谁有想法为此获得解决方案?(可能是一些额外的库或类似的东西)
非常感谢!!
c中这段代码的正确形式是什么?
char *x = malloc(100);
Run Code Online (Sandbox Code Playgroud)
码
#include <stdlib.h>
#include <stdio.h>
int main(){
char *x=malloc(100);
free(x);
//in c++
// char *x=new char[100];
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是错误
1>------ Build started: Project: memory_leaks, Configuration: Debug Win32 ------
1>Build started 8/1/2010 2:32:21 PM.
1>PrepareForBuild:
1> Creating directory "c:\users\david\documents\visual studio 2010\Projects\memory_leaks\Debug\".
1>InitializeBuildStatus:
1> Creating "Debug\memory_leaks.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> memory_leaks.cpp
1>c:\users\david\documents\visual studio 2010\projects\memory_leaks\memory_leaks\memory_leaks.cpp(5): error C2440: 'initializing' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' …Run Code Online (Sandbox Code Playgroud) 我想在c ++中实现一个具有回调的类.
所以我想我需要一个有两个参数的方法:
条件是:
myObj可以来自任何一个类.
将成为回调函数的成员函数是非静态的.
我一直在读这个,但看起来我需要事先了解myObj的类.但我不知道该怎么做.我怎么处理这个?这在C++中是否可行?
这是我想到的,但肯定是不正确的.
class MyClassWithCallback{
public
void *targetObj;
void (*callback)(int number);
void setCallback(void *myObj, void(*callbackPtr)(int number)){
targetObj = myObj;
callback = callbackPtr;
};
void callCallback(int a){
(myObj)->ptr(a);
};
};
class Target{
public
int res;
void doSomething(int a){//so something here. This is gonna be the callback function};
};
int main(){
Target myTarget;
MyClassWithCallback myCaller;
myCaller.setCallback((void *)&myTarget, &doSomething);
Run Code Online (Sandbox Code Playgroud)
}
我感谢任何帮助.
谢谢.
更新大多数人说观察和代表,这就是我正在寻找的,我是一个Objective-C/Cocoa头脑的家伙.我目前的实现是使用具有虚函数的接口.我只是认为传递对象和成员函数指针(如boost!)而不是定义接口会"更聪明".但似乎每个人都认为Interfaces是最简单的方法吗?Boost似乎是一个好主意,(假设已安装)
我有一堆扩展抽象Base类的类.每个子类都采用构造函数中的数组(不同长度取决于类).这些课程可以由其他人编写.
找出类需要的数组长度的最佳方法是什么?我可以:(A)要求每个派生类都有一个静态方法,返回长度.但是,基类不能强制执行此操作,因为抽象静态方法在java中不起作用.(B)每个派生类都有一个没有参数的构造函数,我构造这样的类只是为了能够调用countParameters()方法,我可以从Base类强制执行.这感觉"笨拙",因为我对创建这样的对象不感兴趣,但只需要一些关于它的信息.
原因是我正在创建一个GUI,它使用户能够创建Derived类的实例,但每个Derived类都使用不同数量的参数.也就是说,我需要知道如何在创建类之前绘制GUI.
编辑:我可以要求每个Derived类都有一个私有构造函数,没有参数,并且使用反射我可以调用countParameters()方法.
EDIT2:实际上,我感兴趣的是参数的名称是什么.也就是说,如果Derived类具有构造函数
public Derived(double name1,double name2,...)
Run Code Online (Sandbox Code Playgroud)
我需要一种方法来生成String []数组
{name1,name2,...}
Run Code Online (Sandbox Code Playgroud)
我想如果不创建类的实例就不可能做到,但是为了让用户能够创建这样的类,他/她需要参数名称!片刻22.
基本上我需要选择一个,以便我可以快速熟悉它,然后根据我的需要进行自定义.
我是.NET开发人员,也知道经典的ASP.但我认为理解PHP对我来说不是问题,也认为它不会那么困难.
你想推荐我什么?
更新: -
抱歉我迟到了这个信息.现在我不知道我将做什么样的定制.但我相信我会继续我有自己的要求,需要定制.所以我不想处于这样的情况,我将不得不说"我正在使用的这个引擎不允许我更改XYZ,或者我在这个博客软件中进行XYZ更改会很困难,所以我们要迁移别的."
我更喜欢简短的学习曲线.
这是代码.
public class testClient {
public static void main(String[] args) {
testClient abc = new testClient();
abc.go();
}
public void go() {
try {
Socket s = new Socket("127.0.0.1", 5000);
InputStreamReader sr = new InputStreamReader(s.getInputStream());
BufferedReader reader = new BufferedReader(sr);
String x = reader.readLine();
System.out.println(x);
reader.close();
} catch(IOException ex) {
ex.printStackTrace();
}
}
}
public class testServer {
public static void main(String[] args) {
testServer server = new testServer();
server.go();
}
public void go() {
try {
ServerSocket s = …Run Code Online (Sandbox Code Playgroud) 当我突出显示" class = div "中的任何文本时,我想显示工具提示.我有以下HTML:
<div class='test'>Test</div>
<div class='tooltip'>Tooltip 1</div>
<div class='test'>Test 2</div>
<div class='tooltip'>Tooltip 2</div>
<div class='test'>Test 4</div>
<div class='tooltip'>Tooltip 4</div>
Run Code Online (Sandbox Code Playgroud)
和以下javascript:
<script type="text/javascript">
$(document).ready(function () {
$('div.test').each(function () {
var tooltipHtml = //NEED to figure out how get the html of the Tooltip div below this current div
$(this).qtip({
content: {
text: tooltipHtml
},
style: { width: 450 }
});
});
});
Run Code Online (Sandbox Code Playgroud)
我如何从"下一个"工具提示div获取html?
java ×3
asp.net-mvc ×1
blogs ×1
c ×1
c++ ×1
callback ×1
class ×1
class-design ×1
codeigniter ×1
jquery ×1
math ×1
networking ×1
points ×1
qtip ×1
regions ×1
session ×1
sql ×1
tdd ×1
unit-testing ×1
wordpress ×1