what is the difference between stensi & WanWizard datamaper versions? - codeigniter-datamapper

I've tried stensi but I see it has some mistakes and unexpected output as mentioned in the user guide.
For example, when trying to delete a record it gives this error:
$p=new Per();
$p->where('id',1)->get();
$p->delete();
with an error message of:
undefined index id
when
echo $p->UserName;
outputs:
mhmd
and WanWizard has also this error:
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message: array_key_exists() expects parameter 2 to be array, boolean given</p>
<p>Filename: libraries/datamapper.php</p>
<p>Line Number: 399</p>
How can I overcome these errors or what can I do to make it work properly?

I've changed the two lines of code at ../libraries/datamapper.php line 399 (WanWizard version):
$d = array($this->config->item('datamapper'));
DataMapper::$config = $d;
and the error message disappeared.
If anyone has tried DataMapper and has a better suggestion, please let us know.

just found out this error can occur if you autoload the datamapper config file

Stensi's original version hasn't been maintained since 2007, and only supports CI 1.4. Not really an option anymore these days. It was forked by Overzealous in 2008, and I took over maintenance of that fork in 2010.

I fixed this (in the CI spark version) by moving the config file from the sparks directory to the /application/config directory.

There's something strange happening in CI v2.1.4 where
$this->config->load('datamapper', TRUE, TRUE);
on line 391 of application/libraries/datamapper.php in Datamapper-ORM v1.8.2.1 isn't "namespacing" the config correctly. If you do
print_r ($this->config); die;
just after line 391, you'll see all of the config values are in the general CodeIgniter "namespace" inside the loaded config array. The least intrusive way to get around this is to manually namespace your application/config/datamapper.php file yourself, by changing all the references from
$config['prefix'] = '';
$config['join_prefix'] = '';
...
to
$config['datamapper']['prefix'] = '';
$config['datamapper']['join_prefix'] = '';
...
That's how I got around it. Though #Mhmdgomma's fix does work, I prefer not to hack the core of the system when there is a simpler solution available. Someone should probably get the maintainers to fix this, but I'm not sure where the issue lies. It looks more like it's a CI issue, rather than DM.

Related

Make dolthub/dolthub-etl-jobs/tree/master/loaders/nvd use newer CVE scheme

I am trying to get some code to run which is here, on GitHub:
https://github.com/dolthub/dolthub-etl-jobs/tree/master/loaders/nvd
Once I've cloned the repo I run the run.sh script and it fails with the below:
./run.sh
1 synchronisation error:
unexpected http response from "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-2002.meta" ("404 Not Found"): ""
cloning https://doltremoteapi.dolthub.com/Liquidata/NVD
For this to have a chance of working I need to change wherever this is referenced:
https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-20XX.meta
to:
https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-20XX.meta
The old reference is no longer valid.
However, it's impossible to see where the script is actually calling that URL from. Probably I do not know near enough about how go and GitHub hang together.
If I could figure it out, maybe I could just pull down the code and edit it manually once it was on my host or even create a fork with the new URL in it.
Find where the URL is actually coming from when I call run.sh which errors out almost immediately.
Make a change that reflects the valid one.
TLDR: Replace 4 by 6 in line 44 of main.go.
go.mod from https://github.com/dolthub/dolthub-etl-jobs/tree/master/loaders/nvd
requires github.com/facebookincubator/nvdtools but replaces this by github.com/liquidata-inc/nvdtools which redirects to github.com/dolthub/nvdtools which is an archived repo(!) (cf. https://github.com/dolthub/dolthub-etl-jobs/blob/d858a2433f68d72dc643e26085a5a0c44edbb85c/loaders/nvd/go.mod#L5-L7).
Supported CVE feeds of dolthub/nvdtools are defined here: https://github.com/dolthub/nvdtools/blob/e67111c0fff487cc15cd2ba32668141622cf9c63/providers/nvd/cve.go#L44-L53
cve10jsonGz is 4, cve11jsonGz is 6
main.go sets the CVE feed here: https://github.com/dolthub/dolthub-etl-jobs/blob/d858a2433f68d72dc643e26085a5a0c44edbb85c/loaders/nvd/main.go#L43.
Change it from 4 to 6.
I didn't test the rest of run.sh, but at least the problem you're mentioning in your question should be solved.

String(4) "asas" is throen in the console while running artisan command laravel

I encountered a strange error today where the error looks like in the image:
I cloned my one of my colleague's repository and ran composer install command.
As it tried to generate optimized files, the error started popping out. After that, if I try to run any artisan command, it throws the same error text string(4) "asas".
To be more precise, I already have .env configured.
Please help. Am I really missing something that I need to look at?
The most likely explanation is that your colleague dumped asas somewhere in the code base. Probably in a place that is loaded everytime you execute a command, like a service provider.
Just search for asas in all files and you'll find something like:
dd('asas');
//or
var_dump('asas');
die;
Since asas is only the result, it may be a variable, like dd($test); where asas is the value.
If you don't find anything, search for dd or var_dump.

go-swagger restapi/configure_todo_list.go - api.TodoGetHandler undefined error

I am a newbie in go and go-swagger. I am following steps in Simple Server tutorial in goswagger.io.
I am using Ubuntu 18.04, swagger v0.25.0 and go 1.15.6.
Following the same steps, there are a few differences of the files generated. For instance, goswagger.io's has find_todos_okbody.go and get_okbody.go in models but mine does not. Why is that so?
Link to screenshot of my generated files vs
Link to screenshot of generated files by swagger.io
Starting the server as written in the tutorial go install ./cmd/todo-list-server/ gives me the following error. Can anyone please help with this?
# my_folder/swagger-todo-list/restapi
restapi/configure_todo_list.go:41:8: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
restapi/configure_todo_list.go:42:6: api.TodosGetHandler undefined (type *operations.TodoListAPI has no field or method TodosGetHandler)
The first step in goswagger.io todo-list is swagger init spec .... Which directory should I run this command in? I ran it in a newly created folder in my home directory. However, from the page, it shows the path to be ~/go/src/github.com/go-swagger/go-swagger/examples/tutorials/todo-list. I am not sure whether I should use go get ..., git clone ... or create those folders. Can someone advise me?
Thanks.
This is likely the documentation lagging behind the version of the code that you are running. As long as it compiles, the specific files the tool generates isn't so crucial.
This is a compilation error. When you do go install foo it will try to build the foo package as an executable and then move that to your GOPATH/bin directory. It seems that the generated code in restapi/configure_todo_list.go isn't correct for the operations code generated.
All you need to run this tutorial yourself is an empty directory and the swagger tool (not its source code). You run the commands from the root of this empty project. In order not to run into GOPATH problems I would initialise a module with go mod init todo-list-example before doing anything else.
Note that while the todo-list example code exists inside the go-swagger source, it's there just for documenting example usage and output.
What I would advice for #2 is to make sure you're using a properly released version of go-swagger, rather than installing from the latest commit (which happens when you just do a go get), as I have found that to be occasionally unstable.
Next, re-generate the entire server, but make sure you also regenerate restapi/configure_todo_list.go by passing --regenerate-configureapi to your swagger generate call. This file isn't always refreshed because you're meant to modify it to configure your app, and if you changed versions of the tool it may be different and incompatible.
If after that you still get the compilation error, it may be worth submitting a bug report at https://github.com/go-swagger/go-swagger/issues.
Thanks #EzequielMuns. The errors in #2 went away after I ran go get - u -f ./... as stated in
...
For this generation to compile you need to have some packages in your GOPATH:
* github.com/go-openapi/runtime
* github.com/jessevdk/go-flags
You can get these now with: go get -u -f ./...
I think it's an error of swagger code generation. You can do as folloing to fix this:
delete file configure_todo_list.go;
regenerate code.
# swagger generate server -A todo-list -f ./swagger.yml
Then, you can run command go install ./cmd/todo-list-server/, it will succeed.

Fatal error: Class 'Category' not found after PHP version upgrade

I use CodeIgniter 2.1 and my production server was updated to PHP 5.4.3-1, and the pages that uses phpactiverecord don´t show nothing and don't show any error.
In my test servers with 5.3.6 works fine.
I use the nightly build version of May 2012. I try with the older versions and stable version.
Php-activerecord don´t work fine with php 5.4.3?
EDIT: I found that my new server doesn´t have displays_errors = ON. After activate it, I see the error:
Fatal error: Class 'Category' not found in /srv/www/framework/application/controllers/categories.php on line 26
at line 26:
$data["categories"] = Category::findby($parent_id);
categories.php exists in /srv/www/framework/application/controllers/ and this works fine on PHP 5.3.6.
I need to call something more or call at a different way?
I found the solution.
This solution is for php-activerecord through the latest SPARKS version.
Debugging the autoload_function, I´ve seen that the model file was loaded with the first letter capitalized, only in PHP 5.4.3, not in 5.3.x, and the file wash´t loaded.
Find the ActiveRecord.php at
yourfolder/sparks/php-activerecord/0.0.0.2/vendor/php-activerecord
Search the function:
activerecord_autoload($class_name)
Line 49 change:
$file = $root.DS.$file_name;
for
$file = $root.DS.strtolower($file_name);
And now it works!
p.d. I have found another strange case with PHP 5.4.3 before solve this. The function parse_url() returns false if your database password has a '/' on the string. Because of this, php-activerecord could not connect to the database in the file yourfolder/sparks/php-activerecord/0.0.0.2/vendor/php-activerecord/lib/connection.php at function: file parse_connection_url().
On PHP 5.3 returns the correct array.

Call to undefined function mysql_connect [duplicate]

This question already has answers here:
Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2
(2 answers)
Closed 3 months ago.
I just installed PHP and Apache on my home PC. When I try to call function mysql_connect I get:
fatal error: call to undefined function mysql_connect.
I have loaded php.ini where I have uncommented lines extension=php_mysql.dll and
extension=php_mysqli.dll and changed extension directory to extension_dir = "C:\php\ext" - which is the directory where files php_mysql.dll and php_mysqli.dll are. How can I fix this problem?
Output of phpinfo():
http://jsfiddle.net/MMTwA/
After looking at your phpinfo() output, it appears the mysql extensions are not being loaded. I suspect you might be editing the wrong php.ini file (there might be multiple copies). Make sure you are editing the php file at C:\php\php.ini (also check to make sure there is no second copy in C:\Windows).
Also, you should check your Apache logs for errors (should be in the \logs\ directory in your Apache install.
If you haven't read the below, I would take a look at the comments section, because it seems like a lot of people experience quirks with setting this up. A few commenters offer solutions they used to get it working.
http://php.net/manual/en/install.windows.extensions.php
Another common solution seems to be to copy libmysql.dll and php_mysql.dll from c:\PHP to C:\Windows\System32.
Background about my (similar) problem:
I was asked to fix a PHP project, which made use of short tags. My WAMP server's PHP.ini had short_open_tag = off.
In order to run the project for the first time, I modified this setting to short_open_tag = off.
PROBLEM Surfaced:
Immediately after this change, all my mysql_connect() calls failed. It threw an error
fatal error: call to undefined function mysql_connect.
Solution:
Simply set short_open_tag = off.
My PC is running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file "httpd.conf" (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf) was sensitive to slashes.
You can check if "php.ini" is read from the right directory. Just type in your browser "localhost/index.php". The code of index.php is the following:
<?php
echo phpinfo();
?>
There is the row (not far from the top) called "Loaded Configuration File". So, if there is nothing added, then the problem could be that your "php.ini" is not read, even you uncommented (extension=php_mysql.dll and extension=php_mysqli.dll). So, in order to make it work I did the following step. I needed to change from
PHPIniDir 'c:\PHP\'
to
PHPIniDir 'c:\PHP'
Pay the attention that the last slash disturbed everything!
Now the row "Loaded Configuration File" gets "C:\PHP\php.ini" after refreshing "localhost/index.php" (before I restarted Apache2.2) as well as mysql block is there. MySQL and PHP are working together!
You have probably forgotten to restart apache/wamp/xamp/whatever webserver you use, you need to do that in order to make it work
Check your php.ini, I'm using Apache2.2 + php 5.3. and I had the same problem and after modify the php.ini in order to set the libraries directory of PHP, it worked correctly. The problem is the default extension_dir configuration value.
The default (and WRONG) value for my work enviroment is
; extension_dir="ext"
without any full path and commented with a semicolon.
There are two solution that worked fine for me.
1.- Including this line at php.ini file
extension_dir="X:/[PathToYourPHPDirectory]/ext
Where X: is your drive letter instalation (normally C: or D: )
2.- You can try to simply uncomment, deleting semicolon. Include the next line at php.ini file
extension_dir="ext"
Both ways worked fine for me but choose yours. Don't forget restart Apache before try again.
I hope this help you.
Hi I got this error because I left out the ampersand (&) in
; php.ini
error_reporting = E_ALL & ~E_DEPRECATED
Be sure you edited php.ini in /php folder, I lost all day to detect error and finally I found I edited php.ini in wrong location.
After change our php.ini, make sure to restart Apache web server.
Just for future reference, copying all these extension files to Windows/System or Windows/System32 is unnecessary.
All that is required is a copy of the php.ini file you edit in the PHP dir to copied to the root Windows dir.
phpinfo will clearly explain the below:
Configuration File (php.ini) Path C:\Windows
Logical sense will explain that php wants to load a config located in the Windows dir. :-)
One time I had a problem while using Off instead of off. And also check the pads one more time... The path has to be exact. Also add the following line to your environmental variable.
C:\your-apache-path\bin; C:\your-php-path\bin;C:\your-mysql-path\bin
If you are in Windows, right click My Computer, select properties, and navigate to the Advanced tab... (is Windows 7). Click on Advanced system settings first then select the Advanced tab and then Environmental variables. Select PATH and click on Edit. Make a copy of the string in a .txt file for back up (it might be empty)--- set your environmental variables... Log out and log back in.
Since mysql_connect This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.
by default xampp does not load it automatically
in your php.ini file you should uncomment
;; extension=php_mysql.dll
to
extension=php_mysql.dll
Then restart your apache you should be fine
This same problem drove me nuts (Windows 10, Apache 2.4, MySql 5.7). For some reason (likely PATH related), the .dlls would not load after uncommenting the correct exension dlls and extension_dir = "ext" in php.ini. After trying numerous things, I simply changed "ext" to use the full directory path. For example. extension_dir = "c:/phpinstall/ext" and it worked.
I think that you should use mysqli_connect instead of mysql_connect

Resources