草庐IT

get_models

全部标签

PHP file_get_contents 很慢并返回 500 Internal Server Error

我正在尝试阅读新闻机构网站的rss并获取所有新闻的多个选项以保存在我的数据库中。所以我使用php函数作为file_get_contents或cURl,但它需要大约一分钟来获取网站内容并分析它以分离我想要的新闻部分。这是我从rss获取新闻数据的代码的一部分:$rss=newDOMDocument();$rss->load('http://isna.ir/fa/Sports/feed');$feed=array();foreach($rss->getElementsByTagName('item')as$node){$item=array('title'=>$node->getElemen

php - 将模型名称作为函数中的参数传递并使用其方法,如 "$this-> $model_name->method()"codeigniter

我如何创建一个方法来用特定模型填充读取特定表格的下拉列表,然后获取该表格的特定列来填充下拉列表?例如,如果我有一个模范人物我有functionget_all_id($id,$table){$this->db->from($table);$this->db->order_by($id,"asc");$q=$this->db->get();return$q;}然后,如果我需要填写一个带有姓氏字段的下拉列表...我会将其用作$this->load->model('person_model');$row=$this->person_model->get_all_id('id_person','

php - 在 url 中隐藏 get 变量

我有一个类似的网址localhost/index?id=2如何使用htaccess隐藏id部分并只显示:localhost/index/2 最佳答案 为了捕获查询字符串,您需要使用%{QUERY_STRING}或%{THE_REQUEST}:Options+FollowSymLinks-MultiViewsRewriteEngineOnRewriteBase/#Redirect/index?id=2to/index/2RewriteCond%{THE_REQUEST}^[A-Z]{3,}\s/+index\?id=([^&\s]+)

php - Phalcon\Mvc\Model 序列化 - 对象属性丢失

序列化Phalcon\Mvc\Model会丢失不属于架构一部分的对象属性。我有以下模型,它在加载时设置状态数组:classCountryextendsPhalcon\Mvc\Model{protected$states;publicfunctioninitialize(){$this->setSource('countries');}publicfunctionafterFetch(){if($this->id){$this->states=['AL','AZ','NV','NY'];}}}我这样做:$country=Country::findFirst($countryId);$se

php - 通过 url 重写访问 $_GET[] 数组

我正在为美发沙龙建立网站。我得到了我需要的所有时间,所以我开始构建我的MVC框架只是为了更好地理解MVC。MVC的核心是url重写。RewriteRule^(.*)/?$index.php?url=$1[L]这会导致...www.example.com/register$_GET['url']='register'我决定制作页面发布/重定向/获取模式。所以当我重定向时,url应该是这样的......www.example.com/register/John/Doe/mail或类似的东西。该值完全在$_GET['url']变量中。有没有办法让url看起来像这样...www.example

php - 拉维尔 4 : Model Relationships Not Working (sort of)?

我的Laravel4项目中有3个模型:Employee、EmployeeClass、Employer:classEmployeeextendsEloquent{protected$table='users';publicfunctionemployee_class(){return$this->belongsTo('EmployeeClass','employee_class_id');}}classEmployeeClassextendsEloquent{protected$table='employee_classes';publicfunctionemployees(){retu

php - PHP 中的 YouTube 分析 API : I keep getting "Insufficient permissions" while authenticated

我正在尝试使用OAUTH2在PHP中访问YouTubeAnalyticsAPI。在我的场景中,我首先检索channel数据,它工作正常(即使使用经过身份验证的段)。然后我在我的Analytics-call中解析channel-id。YouTubeAnalyticsAPI在我的GoogleDeveloperConsole中激活。我最终遇到以下错误:Anclienterroroccurred:ErrorcallingGEThttps://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3D##MY_CHANNEL

php - 无法对来 self 的服务器 (php) 的某些 url 使用 file_get_contents()

所以我正在向一个url发出一个get请求,一个https://地址,我只想从中接收一个小文本。这在本地主机上工作正常,但是当我在我的网络服务器(由one.com托管)上执行时,它不起作用。它显示此错误:Warning:file_get_contents():SSLoperationfailedwithcode1.OpenSSLErrormessages:error:14077458:SSLroutines:SSL23_GET_SERVER_HELLO:reason(1112)in/customers/0/4/f/mydomain.se/httpd.www/test.phponline4

php - 使用 $this->input->get() 时缺少 @ 符号

我目前正在练习制作一个joomlaMVC组件,到目前为止一切正常,除了当我提交一个带有这样的元素的表单时例如下面的值email@domain.com我在JControllerLegacy中得到的是emaildomain.com。注意缺少的@。我通过以下方式获取表单值$email=$this->input->get('email');这是我不知道的Joomla功能吗? 最佳答案 试试这个,上述问题是因为Joomla过滤器options.你可以试试这样的,$email=$this->input->get('email',null,'st

Php 序列号 : No stty available -- cant seem to get it working

我正在从事一个项目,该项目涉及使用我的RaspberryPi上的UART引脚读取和写入串口板。但是,我已经碰壁了。每当我尝试使用PhpSerial时,我总是会收到错误消息:Fatalerror:Nosttyavailable,unabletorun.in/var/www/PHP-Serial/examples/PhpSerial.phponline56我尝试了多种输入配置://Firstwemustspecifythedevice.Thisworksonbothlinuxandwindows(if//yourlinuxserialdeviceis/dev/ttyS0forCOM1,et