Here is my model file;
function yaklasan_maclar_tenis() {
$data = $this->cache->memcached->get('yaklasan_tenis');
if (!$data){
$this -> db -> limit(10);
$data = array();
foreach ($this->db->get_where('maclar', array('durum' => '1', 'sonuclandi' => '0', 'tarih >=' => time(), 'spor' => '5'))->result_array() as $row) {
$data[] = array(
'id' => $row['id'],
'matchid' => $row['matchid'],
'spor' => $row['spor'],
'ulke' => $row['ulke'],
'turnuva' => $row['turnuva'],
'takim1' => $row['takim1'],
'takim2' => $row['takim2'],
'tarih' => $row['tarih'],
'istatistik' => $row['istatistik'],
);
}
$this->cache->memcached->save('yaklasan_tenis',$data, 600);
}
return $data;
}
I'm sure that I installed memcached properly but getting this error when I call this function:
Fatal error: Call to a member function get() on a non-object in /home/mydomain/public_html/system/libraries/Cache/drivers/Cache_memcached.php on line 79
Here is the lines 77-82, Cache_memcached.php file:
public function get($id)
{
$data = $this->_memcached->get($id); //this line is 79
return is_array($data) ? $data[0] : $data;
}
I made my research on site but couldn't find anything about it. I just found something and tried the suggestion but nothing changed.
Thanks in advance.
Did you load the caching drive?
Something likes:
$this->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file'));
Related
I am getting this error:
Fatal error: Cannot redeclare class apiException in E:\Applications\xampp\htdocs\onlineshop\application\third_party\google-login-api\apiClient.php on line 367
What does it mean?
What should I do to fix it? Add exception in my controller or anything else?
Please help me.
Here's my code
public function gplus_login(){
if(isset($_GET['code'])){
$this->googleplus->getAuthenticate();
$user_profile2 = $this->googleplus->getUserInfo();
$username2 = $user_profile2['email'];
$password2 = $user_profile2['email'];
$member_status2 = 1;
$result2 = $this->m_member->check_login($username2, $password2, $member_status2);
if($result2 == TRUE){
$user2 = $this->m_member->by_id(array('member_username'=>$username2));
$newdata2 = (array(
'username_front' => $username2,
'member_id' => $user2->member_id,
'member_fullname' => $user2->member_fullname,
'logged_in_front' => TRUE
));
$this->session->set_userdata($newdata2);
redirect('home');
}
else{
$data2 = array(
'member_gplus_id' => $user_profile2["id"],
'member_fullname' => $user_profile2["name"],
'member_email' => $user_profile2["email"],
'member_username' => $user_profile2["email"],
'member_password' => md5($user_profile2["email"]),
'member_status' => 1,
'member_isreseller' => 0,
'member_login' => 0,
'created_by' => $user_profile2["name"],
'created_on' => date('Y-m-d H:i:s'));
$this->m_member->insert($data2);
$user3 = $this->m_member->by_id(array('member_username'=>$username2));
$newdata3 = (array(
'username_front' => $username2,
'member_id' => $user3->member_id,
'member_fullname' => $user3->member_fullname,
'logged_in_front' => TRUE
));
$this->session->set_userdata($newdata3);
redirect("account");
}
}
else{
$this->session->set_flashdata("Login Error");
redirect("home");
}
}
I think apiException has been included more than 1 time in source code.
Make sure its being used only one time in your source code.
I'm running:
- debian-linux-gnu
- codeigniter 2.2.0
- No physical links in db (legacy)
- version: 5.5.41-MariaDB-1~precise-log
Problem:
I'm writing a blog system for a webshop. After filling in the form (with ckeditor for the actual blog), I do a redirect to the reading page/view:
redirect("/blog/read/" . $blog_id, "refresh"); Only no data is found. When I refresh the page manualy imediatly after, the blog shows just fine.
I tried to sleep the process, but this didn't help. So I think it is not a db issue. Since the view is new for this particular post, no caching.
controller:
public function add_do() {
//Image handling
if (!empty($_FILES['blog_file_img'])) {
$path = $_FILES['blog_file_img']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
$fileData = $this->upload('blog_file_img', $this->now . '.' . $ext);
$fileNames = $this->resize($fileData);
}
//Create blog
$blog_data = array(
"blog_img_original" => $fileData['file_name'],
"blog_img_small" => $fileNames["small"],
"blog_img_medium" => $fileNames['medium'],
"blog_img_big" => $fileNames['big'],
"blog_date_added" => $this->now,
"blog_date_modified" => $this->now,
"blog_created_by" => $this->user['userid'],
"blog_modified_by" => $this->user['userid']
);
//Create blog description
$blog_description_data = array(
'language_id' => 1,
'blog_title' => $this->input->post('blog_title', true),
'blog_desc' => $this->input->post('blog_desc', true),
'blog_text' => $this->input->post('blog_text', false)
);
$data = array_merge($blog_data, $blog_description_data);
$blog_id = $this->blog_model->blog_new($data);
redirect("/blog/read/" . $blog_id, "refresh");
}
read controller:
public function read($id){
$this->_get_message();
$blog_data = $this->blog_model->blog_entry($id);
$this->load->view('header', $this->data_view);
$this->load->view('blog/blog_entry', array('blog_data' => $blog_data));
$this->load->view('blog/blog_right', array('blog_stats' => $this->blog_model->blog_most_popular()));
$this->load->view('footer');
$this->_debug();
}
model for add
public function blog_new($data) {
$this->db->trans_start();
//Blog data extraction
$blog_data = array(
"blog_img_original" => $data['blog_img_original'],
"blog_img_small" => $data["blog_img_small"],
"blog_img_medium" => $data['blog_img_medium'],
"blog_img_big" => $data['blog_img_big'],
"blog_date_added" => $data['blog_date_added'],
"blog_date_modified" => $data['blog_date_modified'],
"blog_created_by" => $data['blog_created_by'],
"blog_modified_by" => $data['blog_modified_by']
);
$blog_id = $this->new_blog($blog_data);
//Blog description extraction
$blog_description_data = array(
'blog_id' => $blog_id,
'language_id' => 1,
'blog_title' => $data['blog_title'],
'blog_desc' => $data['blog_desc'],
'blog_text' => $data['blog_text']
);
$this->new_blog_description($blog_description_data);
$this->db->trans_complete();
return $blog_id;
}
private function new_blog($data) {
$this->initialise('blog', 'blog_id');
return $blog_id = $this->create($data);
}
private function new_blog_description($data) {
$this->initialise('blog_description', 'blog_description_id');
return $blog_description_id = $this->create($data);
}
model for read
public function blog_entry($id) {
$this->db->select("*");
$this->db->from("blog");
$this->db->join("blog_description", "blog.blog_id = blog_description.blog_id");
$this->db->join("blog_stats", "blog.blog_id = blog_stats.blog_id");
$this->db->where("blog.blog_id", $id);
$query = $this->db->get();
//Add to views stats
$this->blog_add_view($id);
return $query->result_array();
}
I have created a class using migrate module but I am unable to migrate entities. my class codes are below please check it and tell me whats the problem with it??
<?php
class ItemOrderXMLMigration extends XMLMigration {
public function __construct() {
parent::__construct(MigrateGroup::getInstance('OrderFeed'));
$this->description = t('Migrate entity from XML file');
//$this->softDependencies = array('WineFileCopy');
$fields = array(
'Number' => t('Number'),
'Date' => t('Date'),
'SubTotal' => t('Sub Total'),
'Discount' => t('Discount'),
'ShippingCharges' => t('Shipping Charges'),
'ShippingChargesDiscount' => t('Shipping Charges Discount'),
'NumItems' => t('NumItems'),
'VATPercentage' => t('VAT Percentage'),
'CurrencyCode' => t('Currency Code'),
'PaymentTypeDesc' => t('Payment Type Desc'),
'OrderState' => t('Order State'),
);
$this->map = new MigrateSQLMap($this->machineName,
array(
'Number' => array(
'type' => 'varchar',
'length' => 225,
'not null' => TRUE,
)
),
MigrateDestinationEntityAPI::getKeySchema('entity_example_basic','first_example_bundle')
);
$xml_folder = DRUPAL_ROOT . '/' . drupal_get_path('module', 'products_import') . '/xml/';
$items_url = $xml_folder . 'OrderFeed.xml';
$item_xpath = '/Orders/Item'; // relative to document
$item_ID_xpath = 'Number'; // relative to item_xpath and gets assembled
// into full path /producers/producer/sourceid
$items_class = new MigrateItemsXML($items_url, $item_xpath, $item_ID_xpath);
$this->source = new MigrateSourceMultiItems($items_class, $fields);
$this->destination = new MigrateDestinationEntityAPI('entity_example_basic','first_example_bundle');
$this->addFieldMapping('field_number', 'Number')
->xpath('Number');
$this->addFieldMapping('field_subtotal', 'SubTotal')
->xpath('SubTotal');
$this->addFieldMapping('field_discount', 'Discount')
->xpath('Discount');
//$this->addUnmigratedDestinations(array('weight'));
}
}
?>
When I import it I got the save error message for all entities: Creating default object from empty value File /var/www/mig/migration/sites/all/modules/migrate_extras/entity_api.inc, line 227
Try the latest or updated migrate module https://www.drupal.org/project/migrate. I think you were using old one which were having some issues to migrate entities.
Why don't you try with a feed importer (Feeds module) using XPath parser module?. It's really easy, and you can use both an uploaded file or a source URL.
I have two controllers:
test.php
public function trackback()
{
$this->load->library('trackback');
$tb_data = array(
'ping_url' => 'http://www.citest.com/addtrackback/receive/777',
'url' => 'http://www.citest.com/test/trackback/',
'title' => 'Заголовок',
'excerpt' => 'Текст.',
'blog_name' => 'Название блога',
'charset' => 'utf-8'
);
if ( ! $this->trackback->send($tb_data))
{
echo $this->trackback->display_errors();
}
else
{
echo 'Trackback успешно отправлен!';
}
}
function trackback() sends the trackback information
addtrackback.php
public function receive()
{
$this->load->library('trackback');
if ($this->uri->segment(3) == FALSE)
{
$this->trackback->send_error("Не указан ID записи ");
}
if ( ! $this->trackback->receive())
{
$this->trackback->send_error("Trackback содержит некорректные данные!");
}
$data = array(
'tb_id' => '',
'entry_id' => $this->uri->segment(3),
'url' => $this->trackback->data('url'),
'title' => $this->trackback->data('title'),
'excerpt' => $this->trackback->data('excerpt'),
'blog_name' => $this->trackback->data('blog_name'),
'tb_date' => time(),
'ip_address' => $this->input->ip_address()
);
$sql = $this->db->insert_string('trackbacks', $data);
$this->db->query($sql);
$this->trackback->send_success();
}
function receive() gets trackback and writes it into a table called 'trackbacks' in the database.
But when I try to view the page, it results in the following error:
An unknown error was encountered.
What's causing this error?
are you referencing the library or the function you're in? if ( ! $this->trackback->send($tb_data))
try changing it to something like
public function trackback(){
$this->load->library('trackbackLibrary');
what are you trying to accomplish because it seems like you're attempting to do an if statement for the same process.
if ($this->uri->segment(3) == FALSE)
{
$this->trackback->send_error("Не указан ID записи ");
}
if ( ! $this->trackback->receive())
{
$this->trackback->send_error("Trackback содержит некорректные данные!");
}
Also,
Check your error_log file to see what the actual error its throwing. /var/log or some other places. Depending on your OS
This question is about Dashboard.addNews and Dashboard.publishActivity
Facebook has told the public about its new Dashboard API, however it hasn't provided any updates on its library to use the new code.
So I followed the advice in this link
http://forum.developers.facebook.com/viewtopic.php?pid=197753
to add the new functions to the facebookapi_php5_restlib.php
//dashboard functions
public function dashboard_addNews($uid, $news, $image = null) {
return $this->call_method('facebook.dashboard.addNews',
array('uid' => $uid,
'news' => $news,
'image' => $image));
}
public function dashboard_multiAddNews($uids, $news, $image = null) {
return $this->call_method('facebook.dashboard.multiAddNews',
array('uids' => $uids ? json_encode($uids) : null,
'news' => $news,
'image' => $image));
}
public function dashboard_addGlobalNews($news, $image = null) {
return $this->call_method('facebook.dashboard.addGlobalNews',
array('news' => $news,
'image' => $image));
}
public function dashboard_publishActivity($activity, $image = null) {
return $this->call_method('facebook.dashboard.publishActivity',
array('activity' => $activity,
'image' => $image));
}
public function dashboard_multiIncrementCount($uids) {
return $this->call_method(
'facebook.dashboard.multiIncrementCount', array('uids' => json_encode($uids)));
}
public function dashboard_removeActivity($activity_ids) {
return $this->call_method(
'facebook.dashboard.removeActivity', array('activity_ids' => json_encode($activity_ids)));
}
public function dashboard_setCount($uid, $count) {
return $this->call_method('facebook.dashboard.setCount',
array('uid' => $uid,
'count' => $count));
}
But now when I follow the sample code at
http://wiki.developers.facebook.com/index.php/Dashboard.addNews
$image = 'http://www.martialdevelopment.com/wordpress/wp-content/images/cheezburger-or-dim-mak.jpg';
$news = array(array('message' => 'Your friend #:563683308 just sent you a present!', 'action_link' => array('text' => 'Get Your Gift', 'href' => 'http://www.example.com/gifts?id=5878237')));
$facebook->api_client->dashboard_addNews($user_id, $news, $image);
However it will prompt this error:
[Wed Jan 27 03:42:27 2010] [error] [client 127.0.0.1] PHP Notice: Array to string conversion in /var/local/site/webroot/xxxx/facebookapi_php5_restlib.php on line 2009
the code at that php line is
if (is_array($val)) $val = implode(',', $val);
pls notice that I haven't altered the facebookapi_php5_restlib.php except pasting those suggested dashboard function code.
and when I follow the instruction at http://wiki.developers.facebook.com/index.php/Dashboard.publishActivity and try to use it:
$image = 'http://www.martialdevelopment.com/wordpress/wp-content/images/cheezburger-or-dim-mak.jpg';
$activity = array(array('message' => '{*actor*} just sponsored #:563683308!', 'action_link' => array('text' => 'Sponsor this cause', 'href' => 'http://www.example.com/games?id=5878237')));
$facebook->api_client->dashboard_publishActivity($activity, $image);
it throws out the same error too about "Array to string conversion"
Any suggestion to actually use the new Facebook Dashboard API?
If you don't assign into the same variable, the warning will likely go away:
if (is_array($val)) $stringval = implode(',', $val);
Okay, I found that no need to modify the php class at all.
All we need to do is use the call_method
$news = array(array('message' => 'There is a new level in the dungeon!', 'action_link' => array('text' => 'Play now.', 'href' => 'http://www.example.com/gifts?id=5878237')));
$facebook->api_client->call_method('facebook.dashboard.addGlobalNews', array('news' => $news));