I have followed the zend instructions for implement my web Authentication using a database table.
It's exactly the same code, but when render the page, the following exceptions appears:
Zend\Authentication\Adapter\Exception\RuntimeException
File:
C:\xampp\htdocs\pfc\vendor\ZF2\library\Zend\Authentication\Adapter\DbTable.php
Mensaje:
The supplied parameters to DbTable failed to produce a valid sql statement, please
check table and column names for validity.
produced by this other:
Zend\Db\Adapter\Exception\InvalidQueryException
File:
C:\xampp\htdocs\pfc\vendor\ZF2\library\Zend\Db\Adapter\Driver\Mysqli\Statement.php
Mensaje:
Statement couldn't be produced with sql: SELECT `users`.*, (CASE WHEN `password` = ?
THEN 1 ELSE 0 END) AS `zend_auth_credential_match` FROM `users` WHERE `mail` = ?
Seems to be that Statement.php can not execute the sql of above, but I send the sql by phpmyadmin replacing the ? for strings and work ok.
I am sure that $dbAdapter works ok also because I have tested it and the columns name are
"mail" and "password".
This in my code, also I put the $dbAdapter test code.
$dbAdapter = new DbAdapter(array( //This DbAdapter Work ok sure!!
'driver' => 'Mysqli',
'database' => 'securedraw',
'username' => 'root',
'password' => ''
));
$fp = function($name) use ($dbAdapter) { return $dbAdapter->driver->formatParameterName($name);};
$sql = 'SELECT * FROM ' . $qi('users') . ' WHERE id = ' . $fp('id');
$statement = $dbAdapter->query($sql);
$parameters = array('id' => 1);
$sqlResult = $statement->execute($parameters);
$row = $sqlResult->current();
$mail = $row['mail'];
$password = $row['password']; //until here test $dbAdapter exitly!!
//Start the auth proccess!!
$authAdapter = new AuthDbTableAdapter($dbAdapter);
$authAdapter->setTableName('users')
->setIdentityColumn('mail')
->setCredentialColumn('password');
$authAdapter->setIdentity('josep')
->setCredential('josep');
$authResult = $authAdapter->authenticate(); //This is the fail method!!!
After more research on the subject, I discovered that if changed the driver of the dbAdapter to pdo_mysql, authenticate method works ok.
The problem is I don't want use PDO because the SGBD won't change in the future.
Somebody know because happen this?
This may seems old but I was able to solve this error. This error is caused from you MySQL version.
This one works for me. All you need to do is to remove the driver_options from your db setup, this code is usually located at your global.php or .local.php from your Config file.
Change FROM:
'db' => array(
'driver' => 'Pdo_Mysql',
'dsn' => 'mysql:dbname=dbName;host=localhost',
'username' => 'dbUser',
'password' => 'dbPass',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
TO
'db' => array(
'driver' => 'Pdo_Mysql',
'dsn' => 'mysql:dbname=dbName;host=localhost',
'username' => 'dbUser',
'password' => 'dbPass',
),
Thank you. This solution solved my problem.
Related
Can we upload multiple image to the variation using API. Single image upload can be possible using below code, but not sure about multiple image upload.
$mediaId ='random string';
$url = $images['url'];
$mediaData = array(
array(
'id' => $mediaId,
'mediaFolderId' => $mediaFolderID,
),
);
$mediaDataArr = array(
'payload' => array(
"action" => "upsert",
"entity" => "media",
'payload' => $mediaData,
),
);
$createMedia = $shopware6HelperObj->post('_action/sync', $mediaDataArr);
$urlArr = array(
'url' => $url,
);
$parts = pathinfo($url);
$params = array(
'extension' => $parts['extension'],
'fileName' => $parts['filename'] . '__' . md5(time()),
);
$uploadImage = $shopware6HelperObj->post('_action/media/' . $mediaId . '/upload', $urlArr, $params);
Please suggest if any idea.
I always recommend to try doing that via the Admin Panel and check the Browser's Dev Tools / Network Tab which requests are made. This can give you a good hint on how do to it programmatically.
I'm using the feeds module to import my existing data into Drupal 7 and it works great but I have one issue with the nids it generates.
I want these to match my existing site id's then I can have a nice clean transition between old and new keeping even the same urls.
Two approaches here;
1. Somehow assign these nid's as part of the import.
2. Renumber the nid's after import.
I can't find any module or other code in google to do either so looks like I will have to hack something together myself... has anyone done this before?
-
Could it be as simple as updating all these?
SELECT table_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name = 'nid'
comment
history
location_instance
node
node_access
node_comment_statistics
node_counter
node_revision
search_node_links
taxonomy_index
edit: and these...
SELECT table_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name = 'entity_id'
feeds_item
field_data_body
field_data_comment_body
field_data_field_address
field_data_field_image
field_data_field_state
field_data_field_tags
field_data_field_type
field_data_field_website
field_revision_body
field_revision_comment_body
field_revision_field_address
field_revision_field_image
field_revision_field_state
field_revision_field_tags
field_revision_field_type
field_revision_field_website
Here's what I did in the end...
It seems to all be working correctly, but please be very carefully and make a backup (like I did) before doing anything like this.
header('Content-type: text/plain');
global $database, $tables, $prefix;
$database = // your database
$prefix = 'drupal_';
$tables = array (
'comment' => 'nid',
'history' => 'nid',
'location_instance' => 'nid',
'node' => 'nid',
'node_access' => 'nid',
'node_comment_statistics' => 'nid',
'node_counter' => 'nid',
'node_revision' => 'nid',
'search_node_links' => 'nid',
'taxonomy_index' => 'nid',
'feeds_item' => 'entity_id',
'field_data_body' => 'entity_id',
'field_data_comment_body' => 'entity_id',
'field_data_field_address' => 'entity_id',
'field_data_field_image' => 'entity_id',
'field_data_field_state' => 'entity_id',
'field_data_field_tags' => 'entity_id',
'field_data_field_type' => 'entity_id',
'field_data_field_website' => 'entity_id',
'field_revision_body' => 'entity_id',
'field_revision_comment_body' => 'entity_id',
'field_revision_field_address' => 'entity_id',
'field_revision_field_image' => 'entity_id',
'field_revision_field_state' => 'entity_id',
'field_revision_field_tags' => 'entity_id',
'field_revision_field_type' => 'entity_id',
'field_revision_field_website' => 'entity_id'
);
// Move all nids +10000 (out of the way)
$query = "SELECT nid FROM {$prefix}node WHERE nid < 10000 ORDER BY nid";
echo "$query\n";
$result = $database->query($query);
while($data = $result->fetchRow()) {
echo "Processing nid: {$data['nid']}\n";
changeNodeId($data['nid'], $data['nid'] + 10000);
}
// Move all nids to match guids
// (I originally imported through the feeds module, so used the guids to reorder here, but you can use your own logic as required...)
$query = "SELECT guid, entity_id FROM {$prefix}feeds_item WHERE guid <> entity_id ORDER BY ABS(guid)";
echo "$query\n";
$result = $database->query($query);
while($data = $result->fetchRow()) {
echo "Processing guid: {$data['guid']} (nid: {$data['entity_id']})\n";
changeNodeId($data['entity_id'], $data['guid']);
}
function changeNodeId($old, $new)
{
global $database, $tables, $prefix;
echo "Updating nid: {$old} -> {$new}\n";
// Check new doesn't already exist
$query = "SELECT * FROM {$prefix}node WHERE nid={$new}";
$result = $database->query($query);
if ($result->fetchRow()) {
echo "Error nid: {$new} already exists!\n";
return;
}
foreach ($tables as $table => $column)
{
$query = "UPDATE {$prefix}{$table} SET {$column} = {$new} WHERE {$column} = {$old}";
echo "$query\n";
$database->query($query);
}
}
Notes.
The tables listed above worked for me, it will almost definitely be different for you depending on what modules you have installed.
This will break your menus and any URL aliases you have set, so you have to go through manually afterwards and fix these up, not a major though.
Also good idea to reset your auto increment id on the node table. ALTER TABLE node AUTO_INCREMENT = X where X is 1 greater than the highest nid.
If your source contains the original nids, you can just set a mapping in your feed importer to assign the nid. This way there should be no reason to manipulate the db subsequent to the import process, as each node will simply be assigned the same nid.
Obviously this may break if you have existing nodes in your site with the same nids.
Getting all customer list and create a new customer using soap api...
$proxy = new SoapClient('http://j-shop.z/shop/api/soap/?wsdl');
// $proxy = new SoapClient(null, array('uri' => http://j-shop.z/shop/api/soap/?wsdl"));
$sessionId = $proxy->login('testuser', 'test123');
var_dump($proxy->call($sessionId, 'customer.list', array('filters', '*')));
$newCustomer = array(
'firstname' => 'First',
'lastname' => 'Last',
'email' => 'test#example.com',
'password_hash' => md5('password'),
'store_id' => 0,
'website_id' => 0
);
$newCustomerId = $proxy->call($sessionId,'customer.create',array($newCustomer));
Open php_soap in your wamp or xammp,
I think its not open,
So firstly you check your php.ini file
also try it
i think problem in api.xml
http://www.magentocommerce.com/api/soap/introduction.html
http://inchoo.net/ecommerce/magento/magento-v2-soap-demystified/
please set fault in api.xml so easily fix it
From what I understand, my problem is that I am (rather, my client is) running an older version of Drupal, specifically Core 6.26 If you're curious about any additional specs, I'll be happy to divulge.
With that out of the way, I made a new module with the following menu hook.
function checkin_menu(){
$items = array();
$items['checkin'] = array(
'title' => 'Checkin'
,'type' => MENU_CALLBACK
,'access arguments' => array('checkin')
,'page callback' => 'checkin'
);
}
The permissions listed out exactly what I expected. There was a section called "Checkin" the same as the module's name as specified in the .info file, and one item to give permissions to "checkin"
Later on I expanded the module to have two different paths. The second one is supposed to be for admins only.
function checkin_menu(){
$items = array();
$items['checkin'] = array(
'title' => 'Checkin'
,'type' => MENU_CALLBACK
,'access arguments' => array('create a checkin')
,'page callback' => 'checkin'
);
$items['checkin_admin'] = array(
'title' => 'Checkin Admin'
,'type' => MENU_CALLBACK
,'access arguments' => array('view all checkins')
,'page callback' => 'device_checkin_page'
);
return $items;
}
Much to my surprise neither "create a checkin" or "view all checkins" is showing up. I still have the original "checkins" showing on the permissions page. I've been hunting for answers for a couple days now. Help a guy out?
Permissions are defined by a different hook, which is hook_perm.
So you should be doing something like this:
/**
* Implementation of the hook_perm()
*/
function checkin_perm() {
return array (
'create a checkin',
'view all checkins',
);
}
<?php
$config['db'] = array (
'host' => 'localhost'
'username' => 'root'
'password' => ''
'dbname' => 'phplogin'
);
$db = new PDO("mysql:host={$config['db']['host']};dbname={$config['db']['dbname']}",
$config['db']['username'], $config['db']['password']);
?>
receives error: "Parse error: syntax error, unexpected ''username'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\webroot\wamp\www\index.php on line 4"
My question is:
Can you highlight or comment on the lines I have to insert my information such as localhost, databasename, table, root, "", etc. Also if you see any changes that need to be made.
When you get errors, you can find the mistake by looking in the error message
The T_CONSTANT_ENCAPSED_STRING parser token error occurs due to an unexpected quote, so all you had to do is look at your code to notice that you don't have commas in the array declaration as stated by Johnny000. You always have to look the error messages and interpret their meaning. That's coding 101 in my opinion.
The error is because you forget to seperate the arrayvalues with ,
Here the right code
<?php
$config['db'] = array (
'host' => 'YOURHOST',
'username' => 'YOURUSERNAME',
'password' => 'YOURPASSWORD',
'dbname' => 'YOURTABLE'
);
$db = new PDO("mysql:host={$config['db']['host']};dbname={$config['db']['dbname']}",
$config['db']['username'], $config['db']['password']);
?>