我是CodeIgniter的新手.这是我的代码:
class User_model extends CI_Model {
function validate_user() {
$this->db->select('*');
$this->db->from('user');
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$validate_user = $this->db->get();
if($validate_user->num_rows == 1) {
return TRUE;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的模型文件中收到此错误:
Call to a member function select() on a non-object
Run Code Online (Sandbox Code Playgroud)
目前我正在使用CodeIgniter 2.1.0版.请帮我!
我有oop php代码:
class a {
// with properties and functions
}
class b extends a {
public function test() {
echo __CLASS__; // this is b
// parent::__CLASS__ // error
}
}
$b = new b();
$b->test();
Run Code Online (Sandbox Code Playgroud)
我有一些父类(普通和抽象)和许多子类.子类扩展父类.因此,当我在某个时刻实例化孩子时,我需要找出我叫的父母.
例如,函数b::test()
将返回a
我如何(从我的代码中)获得a
班级b的课程?
谢谢
$xml
是一个SimpleXML
对象.
print_r($xml->Title);
Run Code Online (Sandbox Code Playgroud)
输出 SimpleXMLElement Object ( [0] => K&H 3093 Extreme Weather Kitty Pad with Fleece Cover )
如何访问第一个元素?
print_r($xml->Title[0]);
Run Code Online (Sandbox Code Playgroud)
没有输出!
我想知道是否可以通过命令行设置base_url.例
bin/behat --base_url=http://google.fr
Run Code Online (Sandbox Code Playgroud)
我想避免创建一个新的配置文件,并在每次我必须测试一个新的url时通过命令行传递它,以实现灵活性.
这有什么诀窍吗?
谢谢.
所以这是我的代码
public void BubbleSort<T>(T[] array) where T : IComparable<T>
{
for (int i = 0; i < array.Length; i++)
{
for (int j = 1; j < array.Length; j++)
{
if (array[j] < array[j - 1])
{
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在拍摄之前不要搜索.我已经搜索了,其中一个答案在SO上说要使用一个可比较的接口来解决问题.
不幸的是,我不会在这个错误的任何地方.
我在elasticsearch中上传了JSON文件,我的映射包含一些嵌套对象.
问题是,在Kibana中,在visualize中我看不到它们
这是我的映射:
"comments": {
"type": "nested",
"properties": {
"count": {
"type": "integer"
},
"data": {
"type":"nested",
"properties": {
"created_time": {
"type": "integer"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是在插入comments.count的 kibana中我看不到任何结果,但在Discover页面中,comments.count字段存在!
我该如何搜索这个字段?
我正在尝试将新的模拟EF6应用到我现有的代码中.
我有一个扩展DbSet的类.其中一个方法调用基类(BdSet)Create方法.这是一个示例代码(不是完整的解决方案或真实姓名):
public class DerivedDbSet<TEntity> : DbSet<TEntity>, IKeyValueDbSet<TEntity>, IOrderedQueryable<TEntity> where TEntity : class
{
public virtual bool Add(string value1, string value2) {
var entity = Create(); // There is no direct implementation of the Create method it is calling the base method
// Do something with the values
this.Add(entity);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在嘲笑使用Test Doubles样本(这是代码的和平):
var data = new List<DummyEntity> {
new DummyEntity { Value1 = "First", Value2 = "001" },
new DummyEntity { Value1 = "Second", Value2 = "002" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试刷新页面,而不是从上一次发送POST.
我试过了
window.open("postme.php?r=t", "_self");
Run Code Online (Sandbox Code Playgroud)
它附加?r=t
到最后但它似乎没有刷新页面,因为页面显示目录中的一些文件,即使我已经移动或删除它们也没有改变.
你能指定URL window.location.reload();
吗?
有任何想法吗?
谢谢
如果用户未能通过表单验证,那么为了使它们更容易,我们可以这样做:
if(isset($_POST['submit'])) {
$email = $_POST['email'];
//....
}
<input type="text" name="phone" value="<?php echo $phone; ?>" />
<input type="text" name="email" value="<?php echo $email; ?>" />
...
Run Code Online (Sandbox Code Playgroud)
因此,在这种情况下,如果用户因为输入了电子邮件但未输入电话号码而未通过验证,那么当提交页面刷新并警告他们丢失了电话时,电子邮件(他们填写的电子邮件)已经在其中放置并且不需要用户重新输入.
但是,如何"记住"用户为select,radio和checkbox输入选择的值?
是否可以将stream_notification_callback与cURL一起使用?
我想调整我在http://www.php.net/manual/en/function.stream-notification-callback.php找到的示例#1 到我下面的cURL函数来创建/更新文本文件包含下载的字节.
我知道这CURLOPT_PROGRESSFUNCTION
是在PHP 5.3中实现但我运行PHP 5.2我无法升级.
private function Save($url) {
$this->SetTempFileName(time());
$file = fopen($this->GetTempVidFileName(), 'w');
$ckfile = tempnam("/tmp_cookie", "CURLCOOKIE");
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_exec($ch);
curl_close($ch);
fclose($file);
return is_file($this->GetTempFileName());
}
Run Code Online (Sandbox Code Playgroud)
我知道我必须使用file_put_contents来替换像这样的"case STREAM_NOTIFY_PROGRESS"部分......
case STREAM_NOTIFY_PROGRESS:
file_put_contents('progress.txt', $bytes_transferred);
break;
Run Code Online (Sandbox Code Playgroud)
......但我的问题是如何调整这两个代码?提前致谢.